[libmultipath] log the date in "multipathd -d" output
authorChristophe Varoqui <root@xa-s05.(none)>
Thu, 24 Nov 2005 14:27:09 +0000 (15:27 +0100)
committerChristophe Varoqui <root@xa-s05.(none)>
Thu, 24 Nov 2005 14:27:09 +0000 (15:27 +0100)
xa-s05:~/scm/multipath-tools-0.4.7# multipathd/multipathd -d
Nov 24 15:22:18 | mpath0: event checker started
Nov 24 15:22:18 | mpath1: event checker started
Nov 24 15:22:18 | path checkers start up
Nov 24 15:22:18 | mpath1: switch to path group #1
Nov 24 15:22:52 | mpath0: switch to path group #4
Nov 24 15:23:00 | mpath1: switch to path group #3

libmultipath/debug.c

index d7188b9..7a13668 100644 (file)
@@ -7,6 +7,8 @@
 
 #if DAEMON
 #include "log_pthread.h"
+#include <sys/types.h>
+#include <time.h>
 #endif
 
 #include "config.h"
@@ -20,13 +22,23 @@ void dlog (int sink, int prio, char * fmt, ...)
        thres = (conf) ? conf->verbosity : 0;
 
        if (prio <= thres) {
+#if DAEMON
                if (!sink) {
+                       time_t t = time(NULL);
+                       struct tm *tb = localtime(&t);
+                       char buff[16];
+                       
+                       strftime(buff, 16, "%b %d %H:%M:%S", tb); 
+
+                       fprintf(stdout, "%s | ", buff);
                        vfprintf(stdout, fmt, ap);
                        fprintf(stdout, "\n");
                }
-#if DAEMON
                else
                        log_safe(prio + 3, fmt, ap);
+#else
+               vfprintf(stdout, fmt, ap);
+               fprintf(stdout, "\n");
 #endif
        }
        va_end(ap);