qmail multilog localtime patch for daemontools-0.76

For performance issue multilog binary in daemontools logs in TAI format like following:

@400000004a9b768834d8118c status: local 0/500 remote 4/299

You have to pipe output to tai64nlocal binary to see date in human readable format.  This is being annoying while searching in log files.

We created a small patch to enable human readable logging in multilog via localtime function. The new log lines will look like following:

Sat Dec 19 03:02:51 2009  status: local 0/500 remote 0/299

I belive that some people will not like this idea.  We found it useful and wanted to share with open source community.

The patch is located at http://files.endersys.com/patches/daemontools-0.76-localtime.patch


diff -ruN daemontools-0.76.orig/src/multilog.c daemontools-0.76/src/multilog.c
--- daemontools-0.76.orig/src/multilog.c        2001-07-12 19:49:49.000000000 +0300
+++ daemontools-0.76/src/multilog.c     2009-12-19 02:52:09.000000000 +0200
@@ -514,7 +514,8 @@
 }
 if (!linelen)
 if (flagtimestamp) {
-          timestamp(line);
+          /* timestamp(line); */
+          timestamplocal(line);
 line[25] = ' ';
 linelen = 26;
 }
diff -ruN daemontools-0.76.orig/src/timestamp.c daemontools-0.76/src/timestamp.c
--- daemontools-0.76.orig/src/timestamp.c       2001-07-12 19:49:49.000000000 +0300
+++ daemontools-0.76/src/timestamp.c    2009-12-19 02:53:02.000000000 +0200
@@ -1,7 +1,13 @@
+#include <sys/types.h>
+#include <time.h>
+#include <sys/time.h>
+#include <unistd.h>
 #include "taia.h"
 #include "timestamp.h"

 static char hex[16] = "0123456789abcdef";
+time_t lt;
+struct tm *t;

 void timestamp(char s[TIMESTAMP])
 {
@@ -18,3 +24,11 @@
 s[i * 2 + 2] = hex[nowpack[i] & 15];
 }
 }
+
+void timestamplocal(char s[TIMESTAMP])
+{
+      lt = time(NULL);
+      t = localtime(&lt);
+      asctime_r(t, s);
+      s[24] = ' ';
+}
diff -ruN daemontools-0.76.orig/src/timestamp.h daemontools-0.76/src/timestamp.h
--- daemontools-0.76.orig/src/timestamp.h       2001-07-12 19:49:49.000000000 +0300
+++ daemontools-0.76/src/timestamp.h    2009-12-19 02:52:17.000000000 +0200
@@ -4,5 +4,6 @@
 #define TIMESTAMP 25

 extern void timestamp(char *);
+extern void timestamplocal(char *);

 #endif

0 Response to “qmail multilog localtime patch for daemontools-0.76”


  • No Comments

Leave a Reply