Add timestamping to console debug.

This commit is contained in:
Adam Sutton 2012-07-12 11:57:47 +01:00
parent 8ebf5b4254
commit 31669d2d6d

View file

@ -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);
}
}