Mercurial > hg > freeDiameter
changeset 945:284608b307ee
Add timestamp to default logger.
Only add newline if there is none.
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Tue, 12 Feb 2013 11:56:53 +0100 |
parents | 6cdb2a54aaf6 |
children | 5d9229144cac |
files | libfdproto/log.c |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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); }