From 31669d2d6d7045c8e45eba27b9941f3944f94361 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Thu, 12 Jul 2012 11:57:47 +0100 Subject: [PATCH] Add timestamping to console debug. --- src/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index ee6c4fc7..48de6696 100644 --- a/src/main.c +++ b/src/main.c @@ -498,16 +498,19 @@ tvhlogv(int notify, int severity, const char *subsys, const char *fmt, if(log_debug_to_syslog || severity < LOG_DEBUG) syslog(severity, "%s", buf); + /** + * Get time (string) + */ + time(&now); + localtime_r(&now, &tm); + strftime(t, sizeof(t), "%b %d %H:%M:%S", &tm); + /** * Send notification to Comet (Push interface to web-clients) */ if(notify) { htsmsg_t *m; - time(&now); - localtime_r(&now, &tm); - strftime(t, sizeof(t), "%b %d %H:%M:%S", &tm); - snprintf(buf2, sizeof(buf2), "%s %s", t, buf); m = htsmsg_create_map(); htsmsg_add_str(m, "notificationClass", "logmessage"); @@ -531,7 +534,7 @@ tvhlogv(int notify, int severity, const char *subsys, const char *fmt, } else { sgroff = "\033[0m"; } - fprintf(stderr, "%s[%s]:%s%s\n", sgr, leveltxt, buf, sgroff); + fprintf(stderr, "%s%s [%s]:%s%s\n", sgr, t, leveltxt, buf, sgroff); } }