Changeset 0cd7064a1b656cd87e61af14b74ec6c80c341fe6

Show
Ignore:
Timestamp:
03/12/08 23:13:11 (4 months ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1205359991 +0100
git-parent:

[021c332008d24ef503eddc6ad41f3392a5816e60]

git-author:
Rafaël Carré <funman@videolan.org> 1205359991 +0100
Message:

Improvements to syslog logger - by Hans Lambermont

- add PID to syslog and use lowercase vlc (conforming to syslog standards)
- add the command-line verbosity control -v[0-2] to html/text/syslog

logging, such that one can disable f.i. LOG_DEBUG from being offered
to html/text/syslog completely.

- add the priority to the syslog message

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • THANKS

    rf70e66e r0cd7064  
    9898Haakon Meland Eriksen - Norwegian translation 
    9999Han HoJoong <0demon0 at paran dot com> - Korean translation 
     100Hans Lambermont <hans dot lambermont at newtec dot eu> - Syslog improvements 
    100101Hans-Peter Jansen <hpj at urpla.net> - patch for module options handling 
    101102Hannes Domani <ssbssa at yahoo dot de> - Qt4 interfaces patches 
  • modules/misc/logger.c

    r99fab90 r0cd7064  
    9898static void Run     ( intf_thread_t * ); 
    9999 
    100 static void FlushQueue        ( msg_subscription_t *, FILE *, int ); 
     100static void FlushQueue        ( msg_subscription_t *, FILE *, int, int ); 
    101101static void TextPrint         ( const msg_item_t *, FILE * ); 
    102102static void HtmlPrint         ( const msg_item_t *, FILE * ); 
     
    278278        p_intf->p_sys->p_file = NULL; 
    279279#ifdef HAVE_SYSLOG_H 
    280         openlog( "VLC", 0, LOG_DAEMON ); 
     280        openlog( "VLC", LOG_PID|LOG_NDELAY, LOG_DAEMON ); 
    281281#endif 
    282282    } 
     
    306306    /* Flush the queue and unsubscribe from the message queue */ 
    307307    FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file, 
    308                 p_intf->p_sys->i_mode ); 
     308                p_intf->p_sys->i_mode, p_intf->p_libvlc->i_verbose ); 
    309309    msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); 
    310310 
     
    344344    { 
    345345        FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file, 
    346                     p_intf->p_sys->i_mode ); 
     346                    p_intf->p_sys->i_mode, p_intf->p_libvlc->i_verbose ); 
    347347 
    348348        if( p_intf->p_sys->p_rrd ) 
     
    356356 * FlushQueue: flush the message queue into the log 
    357357 *****************************************************************************/ 
    358 static void FlushQueue( msg_subscription_t *p_sub, FILE *p_file, int i_mode ) 
     358static void FlushQueue( msg_subscription_t *p_sub, FILE *p_file, int i_mode, 
     359                        int i_verbose ) 
    359360{ 
    360361    int i_start, i_stop; 
     
    371372             i_start = (i_start+1) % VLC_MSG_QSIZE ) 
    372373        { 
     374            switch( p_sub->p_msg[i_start].i_type ) 
     375            { 
     376            case VLC_MSG_ERR: 
     377                if( i_verbose < 0 ) continue; 
     378                break; 
     379            case VLC_MSG_INFO: 
     380                if( i_verbose < 0 ) continue; 
     381                break; 
     382            case VLC_MSG_WARN: 
     383                if( i_verbose < 1 ) continue; 
     384                break; 
     385            case VLC_MSG_DBG: 
     386                if( i_verbose < 2 ) continue; 
     387                break; 
     388            } 
     389 
    373390            switch( i_mode ) 
    374391            { 
     
    408425static void SyslogPrint( const msg_item_t *p_msg ) 
    409426{ 
    410     int i_priority = LOG_INFO; 
    411  
    412     if( p_msg->i_type  == 0 ) i_priority = LOG_INFO; 
    413     if( p_msg->i_type  == 1 ) i_priority = LOG_ERR; 
    414     if( p_msg->i_type  == 2 ) i_priority = LOG_WARNING; 
    415     if( p_msg->i_type  == 3 ) i_priority = LOG_DEBUG; 
     427    static const int i_prio[4] = { LOG_INFO, LOG_ERR, LOG_WARNING, LOG_DEBUG }; 
     428    int i_priority = i_prio[p_msg->i_type]; 
    416429 
    417430    if( p_msg->psz_header ) 
    418         syslog( i_priority, "%s %s: %s", p_msg->psz_header, 
     431        syslog( i_priority, "%s%s %s: %s", p_msg->psz_header, 
     432                ppsz_type[p_msg->i_type], 
    419433                p_msg->psz_module, p_msg->psz_msg ); 
    420434    else 
    421         syslog( i_priority, "%s: %s", p_msg->psz_module, p_msg->psz_msg ); 
     435        syslog( i_priority, "%s%s: %s", p_msg->psz_module,  
     436                ppsz_type[p_msg->i_type], p_msg->psz_msg ); 
    422437  
    423438}