[vlc-devel] [PATCH] Simplify msg_* priority
Rafaël Carré
rafael.carre at gmail.com
Wed Jul 28 15:56:29 CEST 2010
Remove misused msg_Info(), which really was a more outstanding msg_Dbg()
It is now useless with --verbose-objects
This patch defines msg_Info() to behave like msg_Dbg(), all msg_Info()
occurences should be replaced with msg_Dbg() in the commit (i can do
that because i am a sed god)
Messages now show correctly with --control logger
--verbose / -vv usage is unchanged
---
include/vlc_messages.h | 15 +++++--------
modules/gui/qt4/dialogs/messages.cpp | 4 ---
modules/misc/logger.c | 8 ++----
src/misc/messages.c | 37 +++++----------------------------
4 files changed, 15 insertions(+), 49 deletions(-)
diff --git a/include/vlc_messages.h b/include/vlc_messages.h
index 6bfd5da..73e65b7 100644
--- a/include/vlc_messages.h
+++ b/include/vlc_messages.h
@@ -59,14 +59,11 @@ typedef struct
} msg_item_t;
/* Message types */
-/** standard messages */
-#define VLC_MSG_INFO 0
-/** error messages */
-#define VLC_MSG_ERR 1
-/** warning messages */
-#define VLC_MSG_WARN 2
-/** debug messages */
-#define VLC_MSG_DBG 3
+enum {
+ VLC_MSG_ERR = 0,
+ VLC_MSG_WARN = 1,
+ VLC_MSG_DBG = 2,
+};
static inline msg_item_t *msg_Hold (msg_item_t *msg)
{
@@ -92,7 +89,7 @@ VLC_EXPORT( void, msg_GenericVa, ( vlc_object_t *, int, const char *, const char
#define msg_GenericVa(a, b, c, d, e) msg_GenericVa(VLC_OBJECT(a), b, c, d, e)
#define msg_Info( p_this, ... ) \
- msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, \
+ msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, \
MODULE_STRING, __VA_ARGS__ )
#define msg_Err( p_this, ... ) \
msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, \
diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index 614db13..53bbc10 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -246,10 +246,6 @@ void MessagesDialog::sinkMessage( msg_item_t *item )
switch (item->i_type)
{
- case VLC_MSG_INFO:
- messages->setTextColor( "blue" );
- messages->insertPlainText( " info: " );
- break;
case VLC_MSG_ERR:
messages->setTextColor( "red" );
messages->insertPlainText( " error: " );
diff --git a/modules/misc/logger.c b/modules/misc/logger.c
index bb21c8d..bdea458 100644
--- a/modules/misc/logger.c
+++ b/modules/misc/logger.c
@@ -397,8 +397,7 @@ static void Overflow (msg_cb_data_t *p_sys, msg_item_t *p_item, unsigned overrun
vlc_restorecancel( canc );
}
-static const char ppsz_type[4][11] = {
- ": ",
+static const char ppsz_type[3][11] = {
" error: ",
" warning: ",
" debug: ",
@@ -413,7 +412,7 @@ static void TextPrint( const msg_item_t *p_msg, FILE *p_file )
#ifdef HAVE_SYSLOG_H
static void SyslogPrint( const msg_item_t *p_msg )
{
- static const int i_prio[4] = { LOG_INFO, LOG_ERR, LOG_WARNING, LOG_DEBUG };
+ static const int i_prio[3] = { LOG_ERR, LOG_WARNING, LOG_DEBUG };
int i_priority = i_prio[p_msg->i_type];
if( p_msg->psz_header )
@@ -428,8 +427,7 @@ static void SyslogPrint( const msg_item_t *p_msg )
static void HtmlPrint( const msg_item_t *p_msg, FILE *p_file )
{
- static const char ppsz_color[4][30] = {
- "<span style=\"color: #ffffff\">",
+ static const char ppsz_color[3][30] = {
"<span style=\"color: #ff6666\">",
"<span style=\"color: #ffff66\">",
"<span style=\"color: #aaaaaa\">",
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 063ae60..3f688a0 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -470,21 +470,9 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
if( val == kObjectPrintingEnabled ); /* Allowed */
else if( !bank->all_objects_enabled ) continue;
}
- switch( p_item->i_type )
- {
- case VLC_MSG_INFO:
- case VLC_MSG_ERR:
- if( sub->verbosity < 0 ) continue;
- break;
- case VLC_MSG_WARN:
- if( sub->verbosity < 1 ) continue;
- break;
- case VLC_MSG_DBG:
- if( sub->verbosity < 2 ) continue;
- break;
- }
- sub->func (sub->opaque, p_item, 0);
+ if (sub->verbosity >= p_item->i_type)
+ sub->func (sub->opaque, p_item, 0);
}
vlc_rwlock_unlock (&bank->lock);
msg_Release (p_item);
@@ -504,28 +492,15 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
# define WHITE COL(0,1)
# define GRAY "\033[0m"
- static const char ppsz_type[4][9] = { "", " error", " warning", " debug" };
- static const char ppsz_color[4][8] = { WHITE, RED, YELLOW, GRAY };
+ static const char ppsz_type[3][9] = { " error", " warning", " debug" };
+ static const char ppsz_color[3][8] = { RED, YELLOW, GRAY };
const char *psz_object;
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
msg_bank_t *bank = priv->msg_bank;
int i_type = p_item->i_type;
- switch( i_type )
- {
- case VLC_MSG_ERR:
- if( priv->i_verbose < 0 ) return;
- break;
- case VLC_MSG_INFO:
- if( priv->i_verbose < 0 ) return;
- break;
- case VLC_MSG_WARN:
- if( priv->i_verbose < 1 ) return;
- break;
- case VLC_MSG_DBG:
- if( priv->i_verbose < 2 ) return;
- break;
- }
+ if( priv->i_verbose < i_type )
+ return;
psz_object = p_item->psz_object_type;
void * val = vlc_dictionary_value_for_key (&bank->enabled_objects,
--
1.7.0.4
More information about the vlc-devel
mailing list