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

Split up debug message printing (more readable in my opinion)

parent 4f477ba9
...@@ -435,9 +435,8 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item ) ...@@ -435,9 +435,8 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item )
# define WHITE COL(0,1) # define WHITE COL(0,1)
# define GRAY "\033[0m" # define GRAY "\033[0m"
static const char ppsz_type[4][9] = { "", " error", " warning", " debug" }; static const char msgtype[4][9] = { "", " error", " warning", " debug" };
static const char ppsz_color[4][8] = { WHITE, RED, YELLOW, GRAY }; static const char msgcolor[4][8] = { WHITE, RED, YELLOW, GRAY };
const char *psz_object;
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
msg_bank_t *bank = priv->msg_bank; msg_bank_t *bank = priv->msg_bank;
int i_type = p_item->i_type; int i_type = p_item->i_type;
...@@ -458,7 +457,7 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item ) ...@@ -458,7 +457,7 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item )
break; break;
} }
psz_object = p_item->psz_object_type; const char *objtype = p_item->psz_object_type;
void * val = vlc_dictionary_value_for_key (&bank->enabled_objects, void * val = vlc_dictionary_value_for_key (&bank->enabled_objects,
p_item->psz_module); p_item->psz_module);
if( val == kObjectPrintingDisabled ) if( val == kObjectPrintingDisabled )
...@@ -468,7 +467,7 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item ) ...@@ -468,7 +467,7 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item )
else else
{ {
val = vlc_dictionary_value_for_key (&bank->enabled_objects, val = vlc_dictionary_value_for_key (&bank->enabled_objects,
psz_object); objtype);
if( val == kObjectPrintingDisabled ) if( val == kObjectPrintingDisabled )
return; return;
if( val == kObjectPrintingEnabled ) if( val == kObjectPrintingEnabled )
...@@ -477,22 +476,26 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item ) ...@@ -477,22 +476,26 @@ static void PrintMsg ( vlc_object_t *p_this, const msg_item_t *p_item )
return; return;
} }
int canc = vlc_savecancel ();
/* Send the message to stderr */ /* Send the message to stderr */
utf8_fprintf( stderr, "[%s%p%s] %s%s%s %s%s: %s%s%s\n", FILE *stream = stderr;
priv->b_color ? GREEN : "", int canc = vlc_savecancel ();
(void *)p_item->i_object_id,
priv->b_color ? GRAY : "", flockfile (stream);
p_item->psz_header ? p_item->psz_header : "", fprintf (stream, priv->b_color ? "["GREEN"%p"GRAY"] " : "[%p] ",
p_item->psz_header ? " " : "", (void *)p_item->i_object_id);
p_item->psz_module, psz_object, if (p_item->psz_header != NULL)
ppsz_type[i_type], utf8_fprintf (stream, "%s ", p_item->psz_header);
priv->b_color ? ppsz_color[i_type] : "", utf8_fprintf (stream, "%s %s%s: ", p_item->psz_module, objtype,
p_item->psz_msg, msgtype[i_type]);
priv->b_color ? GRAY : "" ); if (priv->b_color)
fputs (msgcolor[i_type], stream);
#if defined( WIN32 ) || defined( __OS2__ ) fputs (p_item->psz_msg, stream);
fflush( stderr ); if (priv->b_color)
fputs (GRAY, stream);
putc_unlocked ('\n', stream);
#if defined (WIN32) || defined (__OS2__)
fflush (stream);
#endif #endif
funlockfile (stream);
vlc_restorecancel (canc); vlc_restorecancel (canc);
} }
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