diff options
author | jbrjake <[email protected]> | 2008-10-09 00:16:14 +0000 |
---|---|---|
committer | jbrjake <[email protected]> | 2008-10-09 00:16:14 +0000 |
commit | 45307049935e7f3a991957d35f699bb00a288a5b (patch) | |
tree | 982b2af1c3a6ab45c5af29b6ffcd208bf4d7a64f /libhb | |
parent | a6f41219f1a6251da2ae5d31202b88adcce1ffc2 (diff) |
Adds an hb_deep_log() function for multiple levels of debugging verbosity. Level 1 displays when hb_log does (job->verbose == 1) and is now meant for logging that helps in tech support. Level 2 adds memory-related logging like freed buffers, and level 3 is for granular stuff that displays once per sample, frame, packet, etc. The debug level continues to be set when hb_init() is called.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1819 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 38 | ||||
-rw-r--r-- | libhb/hb.c | 7 | ||||
-rw-r--r-- | libhb/internal.h | 8 |
3 files changed, 49 insertions, 4 deletions
diff --git a/libhb/common.c b/libhb/common.c index f0ad9e4a2..073abb977 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -549,6 +549,44 @@ void hb_log( char * log, ... ) fprintf( stderr, "%s", string ); } +int global_verbosity_level; //Necessary for hb_deep_log +/********************************************************************** + * hb_deep_log + ********************************************************************** + * If verbose mode is >= level, print message with timestamp. Messages + * longer than 360 characters are stripped ;p + *********************************************************************/ +void hb_deep_log( hb_debug_level_t level, char * log, ... ) +{ + char string[362]; /* 360 chars + \n + \0 */ + time_t _now; + struct tm * now; + va_list args; + + if( global_verbosity_level < level ) + { + /* Hiding message */ + return; + } + + /* Get the time */ + _now = time( NULL ); + now = localtime( &_now ); + sprintf( string, "[%02d:%02d:%02d] ", + now->tm_hour, now->tm_min, now->tm_sec ); + + /* Convert the message to a string */ + va_start( args, log ); + vsnprintf( string + 11, 349, log, args ); + va_end( args ); + + /* Add the end of line */ + strcat( string, "\n" ); + + /* Print it */ + fprintf( stderr, "%s", string ); +} + /********************************************************************** * hb_error ********************************************************************** diff --git a/libhb/hb.c b/libhb/hb.c index 390e566d2..06b489306 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -69,11 +69,10 @@ hb_handle_t * hb_init_real( int verbose, int update_check ) hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 ); uint64_t date; - /* See hb_log() in common.c */ - if( verbose > HB_DEBUG_NONE ) - { + /* See hb_deep_log() and hb_log() in common.c */ + global_verbosity_level = verbose; + if( verbose ) putenv( "HB_DEBUG=1" ); - } /* Check for an update on the website if asked to */ h->build = -1; diff --git a/libhb/internal.h b/libhb/internal.h index e9828fdb9..5d7f654bb 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -8,6 +8,14 @@ * common.c **********************************************************************/ void hb_log( char * log, ... ); +extern int global_verbosity_level; // Global variable for hb_deep_log +typedef enum hb_debug_level_s +{ + HB_SUPPORT_LOG = 1, // Logging helpful in tech support + HB_MEMORY_LOG = 2, // logging about memory usage + HB_GRANULAR_LOG = 3 // logging on sample-by-sample +} hb_debug_level_t; +void hb_deep_log( hb_debug_level_t level, char * log, ... ); void hb_error( char * fmt, ...); int hb_list_bytes( hb_list_t * ); |