Changeset 497b59e4fc525cca1fd422c0b5ece0672d4d8036

Show
Ignore:
Timestamp:
06/07/08 15:46:17 (5 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1215351977 +0200
git-parent:

[1f4f0a78432bfe8f2aef0b119a181f2e05b3cd29]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1215351923 +0200
Message:

libvlc: Add a --verbose-objects option to select which objects should print their msg.

Sample usage:
--verbose-objects=+input,-all

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_messages.h

    rfbb8255 r497b59e  
    103103VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) ); 
    104104VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) ); 
     105 
     106/* Enable or disable a certain object debug messages */ 
     107#define msg_EnableObjectPrinting(a,b) __msg_EnableObjectPrinting(VLC_OBJECT(a),b) 
     108#define msg_DisableObjectPrinting(a,b) __msg_DisableObjectPrinting(VLC_OBJECT(a),b) 
     109VLC_EXPORT( void, __msg_EnableObjectPrinting, ( vlc_object_t *, char * psz_object ) ); 
     110VLC_EXPORT( void, __msg_DisableObjectPrinting, ( vlc_object_t *, char * psz_object ) ); 
    105111 
    106112/** 
  • src/libvlc-module.c

    r62ec225 r497b59e  
    163163    "standard messages, 1=warnings, 2=debug).") 
    164164 
     165#define VERBOSE_OBJECTS_TEXT N_("Choose which objects should print debug " \ 
     166    "message") 
     167#define VERBOSE_OBJECTS_LONGTEXT N_( \ 
     168    "This is a ',' separated string, each objects should be prefixed by " \ 
     169    "a '+' or a '-' to respectively enable or disable it. The keyword " \ 
     170    "'all' refers to all objects. Note, you still need to use -vvv " \ 
     171    "to actually display debug message.") 
     172 
    165173#define QUIET_TEXT N_("Be quiet") 
    166174#define QUIET_LONGTEXT N_( \ 
     
    19351943                 false ); 
    19361944        change_short('v'); 
     1945    add_string( "verbose-objects", 0, NULL, VERBOSE_OBJECTS_TEXT, VERBOSE_OBJECTS_LONGTEXT, 
     1946                 false ); 
    19371947    add_bool( "quiet", 0, NULL, QUIET_TEXT, QUIET_LONGTEXT, true ); 
    19381948        change_short('q'); 
  • src/libvlc.c

    rc7c7269 r497b59e  
    634634     * Message queue options 
    635635     */ 
     636    char * psz_verbose_objects = config_GetPsz( p_libvlc, "verbose-objects" ); 
     637    if( psz_verbose_objects ) 
     638    { 
     639        char * psz_object, * iter = psz_verbose_objects; 
     640        while( (psz_object = strsep( &iter, "," )) ) 
     641        { 
     642            switch( psz_object[0] ) 
     643            { 
     644                printf("%s\n", psz_object+1); 
     645                case '+': msg_EnableObjectPrinting(p_libvlc, psz_object+1); break; 
     646                case '-': msg_DisableObjectPrinting(p_libvlc, psz_object+1); break; 
     647                default: 
     648                    msg_Err( p_libvlc, "verbose-objects usage: \n" 
     649                            "--verbose-objects=+printthatobject," 
     650                            "-dontprintthatone\n" 
     651                            "(keyword 'all' to applies to all objects)\n"); 
     652                    free( psz_verbose_objects ); 
     653                    return VLC_EGENERIC; 
     654            } 
     655        } 
     656        free( psz_verbose_objects ); 
     657    } 
    636658 
    637659    var_Create( p_libvlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
  • src/libvlc.h

    r9f82d86 r497b59e  
    234234    int                i_verbose;   ///< info messages 
    235235    bool               b_color;     ///< color messages? 
     236    vlc_dictionary_t   msg_enabled_objects; ///< Enabled objects 
     237    bool               msg_all_objects_enabled; ///< Should we print all objects? 
    236238 
    237239    /* Timer stats */ 
  • src/misc/messages.c

    rd666030 r497b59e  
    8888    vlc_mutex_init( &priv->msg_bank.lock ); 
    8989    vlc_mutex_init( &QUEUE.lock ); 
     90    vlc_dictionary_init( &priv->msg_enabled_objects, 0 ); 
     91    priv->msg_all_objects_enabled = true; 
     92 
    9093    QUEUE.b_overflow = false; 
    9194    QUEUE.i_start = 0; 
     
    114117} 
    115118 
     119 
     120/** 
     121 * Object Printing selection 
     122 */ 
     123static void const * kObjectPrintingEnabled = (void *) 1; 
     124static void const * kObjectPrintingDisabled = (void *) -1; 
     125 
     126void __msg_EnableObjectPrinting (vlc_object_t *p_this, char * psz_object) 
     127{ 
     128    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
     129    vlc_mutex_lock( &QUEUE.lock ); 
     130    if( !strcmp(psz_object, "all") ) 
     131        priv->msg_all_objects_enabled = true; 
     132    else 
     133        vlc_dictionary_insert( &priv->msg_enabled_objects, psz_object, kObjectPrintingEnabled ); 
     134    vlc_mutex_unlock( &QUEUE.lock ); 
     135} 
     136 
     137void __msg_DisableObjectPrinting (vlc_object_t *p_this, char * psz_object) 
     138{ 
     139    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
     140    vlc_mutex_lock( &QUEUE.lock ); 
     141    if( !strcmp(psz_object, "all") ) 
     142        priv->msg_all_objects_enabled = false; 
     143    else 
     144        vlc_dictionary_insert( &priv->msg_enabled_objects, psz_object, kObjectPrintingDisabled ); 
     145    vlc_mutex_unlock( &QUEUE.lock ); 
     146} 
     147 
    116148/** 
    117149 * Destroy the message queues 
     
    133165    CloseHandle( QUEUE.logfile ); 
    134166#endif 
     167 
     168    vlc_dictionary_clear( &priv->msg_enabled_objects ); 
     169 
    135170    /* Destroy lock */ 
    136171    vlc_mutex_destroy( &QUEUE.lock ); 
     
    547582 
    548583    psz_object = p_item->psz_object_type; 
     584    void * val = vlc_dictionary_value_for_key( &priv->msg_enabled_objects, 
     585                                               psz_object ); 
     586    if( val == kObjectPrintingDisabled ) 
     587        return; 
     588    if( val == kObjectPrintingEnabled ) 
     589        /* Allowed */; 
     590    else if( !priv->msg_all_objects_enabled ) 
     591        return; 
    549592 
    550593#ifdef UNDER_CE