From fce040eb84683d5f97dbc7e2c1351a5caadcb7b9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 18 Feb 2009 05:09:28 +0000 Subject: [PATCH] (trunk libT) #1828: timestamp for log/debug output --- libtransmission/utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libtransmission/utils.c b/libtransmission/utils.c index 451046c75..2e42784bd 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -332,12 +332,17 @@ tr_msg( const char * file, } else { + char timestr[64]; + if( fp == NULL ) fp = stderr; + + tr_getLogTimeStr( timestr, sizeof( timestr ) ); + if( name ) - fprintf( fp, "%s: %s\n", name, buf ); + fprintf( fp, "[%s] %s: %s\n", timestr, name, buf ); else - fprintf( fp, "%s\n", buf ); + fprintf( fp, "[%s] %s\n", timestr, buf ); fflush( fp ); } } @@ -1403,7 +1408,7 @@ parseNumberSection( const char * str, int len, struct number_range * setme ) char * tmp = tr_strndup( str, len ); errno = 0; - a = strtol( tmp, &end, 10 ); + a = b = strtol( tmp, &end, 10 ); if( errno || ( end == tmp ) ) { success = FALSE; } else if( *end != '-' ) {