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

core: gather message initialization code

Also remove libvlc_int_t.b_color, and (re)print greetings when starting
a new log.
parent 600fae99
...@@ -49,10 +49,6 @@ ...@@ -49,10 +49,6 @@
#include "config/vlc_getopt.h" #include "config/vlc_getopt.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* isatty() */
#endif
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
/* used for one-instance mode */ /* used for one-instance mode */
# include <dbus/dbus.h> # include <dbus/dbus.h>
...@@ -157,35 +153,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -157,35 +153,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/*
* 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"))
{
var_Create (p_libvlc, "verbose", VLC_VAR_INTEGER);
var_SetInteger (p_libvlc, "verbose", -1);
priv->i_verbose = -1;
}
vlc_LogInit (p_libvlc); vlc_LogInit (p_libvlc);
/* Announce who we are (TODO: only first instance?) */
msg_Dbg( p_libvlc, "VLC media player - %s", VERSION_MESSAGE );
msg_Dbg( p_libvlc, "%s", COPYRIGHT_MESSAGE );
msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset );
msg_Dbg( p_libvlc, "configured with %s", CONFIGURE_LINE );
vlc_threads_setup (p_libvlc); vlc_threads_setup (p_libvlc);
/* Load the builtins and plugins into the module_bank. /* Load the builtins and plugins into the module_bank.
......
...@@ -152,10 +152,9 @@ typedef struct libvlc_priv_t ...@@ -152,10 +152,9 @@ typedef struct libvlc_priv_t
{ {
void (*cb) (void *, int, const vlc_log_t *, const char *, va_list); void (*cb) (void *, int, const vlc_log_t *, const char *, va_list);
void *opaque; void *opaque;
signed char verbose;
vlc_rwlock_t lock; vlc_rwlock_t lock;
} log; } log;
signed char i_verbose; ///< info messages
bool b_color; ///< color messages?
bool b_stats; ///< Whether to collect stats bool b_stats; ///< Whether to collect stats
/* Singleton objects */ /* Singleton objects */
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
# include "config.h" # include "config.h"
#endif #endif
#include <stdlib.h>
#include <stdarg.h> /* va_list for BSD */ #include <stdarg.h> /* va_list for BSD */
#ifdef __APPLE__ #ifdef __APPLE__
# include <xlocale.h> # include <xlocale.h>
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
#endif #endif
#include <errno.h> /* errno */ #include <errno.h> /* errno */
#include <assert.h> #include <assert.h>
#include <unistd.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_interface.h> #include <vlc_interface.h>
...@@ -164,7 +166,7 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module, ...@@ -164,7 +166,7 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
va_list ap; va_list ap;
va_copy (ap, args); va_copy (ap, args);
Win32DebugOutputMsg (&priv->i_verbose, type, &msg, format, ap); Win32DebugOutputMsg (&priv->log.verbose, type, &msg, format, ap);
va_end (ap); va_end (ap);
#endif #endif
...@@ -289,19 +291,39 @@ void vlc_LogSet (libvlc_int_t *vlc, vlc_log_cb cb, void *opaque) ...@@ -289,19 +291,39 @@ void vlc_LogSet (libvlc_int_t *vlc, vlc_log_cb cb, void *opaque)
if (cb == NULL) if (cb == NULL)
{ {
cb = priv->b_color ? PrintColorMsg : PrintMsg; #if defined (HAVE_ISATTY) && !defined (WIN32)
opaque = (void *)(intptr_t)priv->i_verbose; if (isatty (STDERR_FILENO) && var_InheritBool (vlc, "color"))
cb = PrintColorMsg;
else
#endif
cb = PrintMsg;
opaque = (void *)(intptr_t)priv->log.verbose;
} }
vlc_rwlock_wrlock (&priv->log.lock); vlc_rwlock_wrlock (&priv->log.lock);
priv->log.cb = cb; priv->log.cb = cb;
priv->log.opaque = opaque; priv->log.opaque = opaque;
vlc_rwlock_unlock (&priv->log.lock); vlc_rwlock_unlock (&priv->log.lock);
/* Announce who we are */
msg_Dbg (vlc, "VLC media player - %s", VERSION_MESSAGE);
msg_Dbg (vlc, "%s", COPYRIGHT_MESSAGE);
msg_Dbg (vlc, "revision %s", psz_vlc_changeset);
msg_Dbg (vlc, "configured with %s", CONFIGURE_LINE);
} }
void vlc_LogInit (libvlc_int_t *vlc) void vlc_LogInit (libvlc_int_t *vlc)
{ {
libvlc_priv_t *priv = libvlc_priv (vlc); libvlc_priv_t *priv = libvlc_priv (vlc);
const char *str;
if (var_InheritBool (vlc, "quiet"))
priv->log.verbose = -1;
else
if ((str = getenv ("VLC_VERBOSE")) != NULL)
priv->log.verbose = atoi (str);
else
priv->log.verbose = var_InheritInteger (vlc, "verbose");
vlc_rwlock_init (&priv->log.lock); vlc_rwlock_init (&priv->log.lock);
vlc_LogSet (vlc, NULL, NULL); vlc_LogSet (vlc, NULL, NULL);
......
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