Commit 4151f94e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

libvlc: initialize message settings early enough

That is to say, before any message gets logged.

Unfortunately, since the modules bank uses logging, and provides the
configuration, the message settings cannot be stored in the
configuration file. All messages could be removed from the bank but
that would hurt debugging in some cases :-/
parent e0746e3a
...@@ -2059,9 +2059,11 @@ vlc_module_begin () ...@@ -2059,9 +2059,11 @@ vlc_module_begin ()
add_integer( "verbose", 0, VERBOSE_TEXT, VERBOSE_LONGTEXT, add_integer( "verbose", 0, VERBOSE_TEXT, VERBOSE_LONGTEXT,
false ) false )
change_short('v') change_short('v')
change_volatile ()
add_obsolete_string( "verbose-objects" ) /* since 2.1.0 */ add_obsolete_string( "verbose-objects" ) /* since 2.1.0 */
add_bool( "quiet", 0, QUIET_TEXT, QUIET_LONGTEXT, false ) add_bool( "quiet", 0, QUIET_TEXT, QUIET_LONGTEXT, false )
change_short('q') change_short('q')
change_volatile ()
#if !defined(WIN32) && !defined(__OS2__) #if !defined(WIN32) && !defined(__OS2__)
add_bool( "daemon", 0, DAEMON_TEXT, DAEMON_LONGTEXT, true ) add_bool( "daemon", 0, DAEMON_TEXT, DAEMON_LONGTEXT, true )
...@@ -2083,6 +2085,7 @@ vlc_module_begin () ...@@ -2083,6 +2085,7 @@ vlc_module_begin ()
#endif #endif
add_bool( "color", true, COLOR_TEXT, COLOR_LONGTEXT, true ) add_bool( "color", true, COLOR_TEXT, COLOR_LONGTEXT, true )
change_volatile ()
add_bool( "advanced", false, ADVANCED_TEXT, ADVANCED_LONGTEXT, add_bool( "advanced", false, ADVANCED_TEXT, ADVANCED_LONGTEXT,
false ) false )
add_bool( "interact", true, INTERACTION_TEXT, add_bool( "interact", true, INTERACTION_TEXT,
......
...@@ -116,12 +116,6 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -116,12 +116,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
priv->p_ml = NULL; priv->p_ml = NULL;
priv->p_dialog_provider = NULL; priv->p_dialog_provider = NULL;
priv->p_vlm = NULL; priv->p_vlm = NULL;
priv->i_verbose = 3; /* initial value until config is loaded */
#if defined( HAVE_ISATTY ) && !defined( WIN32 )
priv->b_color = isatty( STDERR_FILENO ); /* 2 is for stderr */
#else
priv->b_color = false;
#endif
/* Initialize mutexes */ /* Initialize mutexes */
vlc_mutex_init( &priv->ml_lock ); vlc_mutex_init( &priv->ml_lock );
...@@ -162,13 +156,27 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -162,13 +156,27 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
module_EndBank (false); module_EndBank (false);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
/* Find verbosity from VLC_VERBOSE environment variable */ /*
* Message queue options (read-only afterwards)
*/
#if defined (HAVE_ISATTY) && !defined (WIN32)
if (isatty (STDERR_FILENO))
priv->b_color = var_InheritBool (p_libvlc, "color");
else
#endif
priv->b_color = false;
priv->i_verbose = var_InheritInteger (p_libvlc, "verbose");
psz_val = getenv ("VLC_VERBOSE");
if (psz_val != NULL)
priv->i_verbose = atoi (psz_val);
if (var_InheritBool (p_libvlc, "quiet"))
{ {
char *env = getenv( "VLC_VERBOSE" ); var_Create (p_libvlc, "verbose", VLC_VAR_INTEGER);
if( env != NULL ) var_SetInteger (p_libvlc, "verbose", -1);
priv->i_verbose = atoi( env ); priv->i_verbose = -1;
} }
/* Announce who we are (TODO: only first instance?) */ /* Announce who we are (TODO: only first instance?) */
...@@ -204,7 +212,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -204,7 +212,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
module_EndBank (true); module_EndBank (true);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
/* /*
* Support for gettext * Support for gettext
...@@ -381,20 +388,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -381,20 +388,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
dbus_out: dbus_out:
#endif // HAVE_DBUS #endif // HAVE_DBUS
/*
* Message queue options
*/
/* Last chance to set the verbosity. Once we start interfaces and other
* threads, verbosity becomes read-only. */
var_Create( p_libvlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
if( var_InheritBool( p_libvlc, "quiet" ) )
{
var_SetInteger( p_libvlc, "verbose", -1 );
priv->i_verbose = -1;
}
if( priv->b_color )
priv->b_color = var_InheritBool( p_libvlc, "color" );
vlc_CPU_dump( VLC_OBJECT(p_libvlc) ); vlc_CPU_dump( VLC_OBJECT(p_libvlc) );
vlc_object_set_name( p_libvlc, "main" ); vlc_object_set_name( p_libvlc, "main" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment