]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Prepend time to log messages
authorAndreas Öman <andreas@lonelycoder.com>
Mon, 25 Aug 2008 17:11:58 +0000 (17:11 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Mon, 25 Aug 2008 17:11:58 +0000 (17:11 +0000)
main.c

diff --git a/main.c b/main.c
index 719a97b420ac89057b187c330fbfa669f5e0265b..7373195bc1b56259504ae54c32dea2da452a0589 100644 (file)
--- a/main.c
+++ b/main.c
@@ -451,8 +451,12 @@ tvhlog(int severity, const char *subsys, const char *fmt, ...)
   va_list ap;
   htsmsg_t *m;
   char buf[512];
+  char buf2[512];
+  char t[50];
   int l;
-  
+  struct tm tm;
+  time_t now;
+
   l = snprintf(buf, sizeof(buf), "%s: ", subsys);
 
   va_start(ap, fmt);
@@ -465,9 +469,15 @@ tvhlog(int severity, const char *subsys, const char *fmt, ...)
    *
    */
 
+  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();
   htsmsg_add_str(m, "notificationClass", "logmessage");
-  htsmsg_add_str(m, "logtxt", buf);
+  htsmsg_add_str(m, "logtxt", buf2);
   comet_mailbox_add_message(m);
   htsmsg_destroy(m);
 }