# HG changeset patch # User Thomas Klausner # Date 1360666613 -3600 # Node ID 284608b307eef7818abb0dee8c33c09d21691d25 # Parent 6cdb2a54aaf670793af98d9a91793cc56680a9bd Add timestamp to default logger. Only add newline if there is none. diff -r 6cdb2a54aaf6 -r 284608b307ee libfdproto/log.c --- a/libfdproto/log.c Tue Feb 12 11:51:10 2013 +0100 +++ b/libfdproto/log.c Tue Feb 12 11:56:53 2013 +0100 @@ -88,11 +88,17 @@ static void fd_internal_logger( int loglevel, const char *format, va_list ap ) { + char buf[25]; FILE *fstr = fd_g_debug_fstr ?: stdout; /* logging has been decided by macros outside already */ - vfprintf( fd_g_debug_fstr, format, ap); - fprintf(fd_g_debug_fstr, "\n"); + + /* add timestamp */ + fprintf(fd_g_debug_fstr, "%s\t", fd_log_time(NULL, buf, sizeof(buf))); + vfprintf(fd_g_debug_fstr, format, ap); + if (format && (format[strlen(format)-1] != '\n')) { + fprintf(fd_g_debug_fstr, "\n"); + } fflush(fd_g_debug_fstr); }