SDB: Added timestamp to sdb log 91/27491/2
authorshingil.kang <shingil.kang@samsung.com>
Sun, 14 Sep 2014 11:14:17 +0000 (20:14 +0900)
committershingil.kang <shingil.kang@samsung.com>
Sun, 14 Sep 2014 11:23:48 +0000 (20:23 +0900)
Change-Id: I3c477908850faf5d9f8225ad29e116eca393d447
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
src/log.c

index 178014420e5a0f379e327600bd217f77e245aff7..54ee740ea4c7278e7693198cc9ee65162f112b3d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -112,7 +112,15 @@ void logging(LogLevel level, const char *filename, const char *funcname, int lin
             name = log_levels[SDBLOG_INFO].name;
             break;
     }
-    snprintf(fbuf, sizeof(fbuf), "[%s][%s:%s():%d]%s", name, filename, funcname, line_number, fmt);
+    // get time
+    char now_time[100] = {0, };
+    struct tm *now;
+    time_t t;
+    time(&t);
+    now = localtime(&t);
+    strftime(now_time, sizeof (now_time), "%b %d %Y %H:%M:%S", now);
+
+    snprintf(fbuf, sizeof(fbuf), "%s [%s][%s:%s():%d]%s", now_time, name, filename, funcname, line_number, fmt);
     vsnprintf(mbuf, sizeof(mbuf), fbuf, args);
     sdb_mutex_lock(&D_lock, NULL);
     fprintf(stderr, "%s", mbuf);