]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sink: finally implement support for SINK_FMT_{TIMED,ISO}
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Sep 2019 06:03:58 +0000 (08:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Sep 2019 06:13:38 +0000 (08:13 +0200)
These formats add the date with a resolution of the microsecond before the
message fields.

src/sink.c

index bd06f1ebbe2fb0ba6f3ef5b56e41e2b566861b7d..e2270b156b8c8367844c85cf6a28a7fa0a6d1320 100644 (file)
@@ -22,6 +22,7 @@
 #include <common/config.h>
 #include <common/ist.h>
 #include <common/mini-clist.h>
+#include <common/time.h>
 #include <proto/cli.h>
 #include <proto/log.h>
 #include <proto/ring.h>
@@ -149,7 +150,7 @@ ssize_t __sink_write(struct sink *sink, const struct ist msg[], size_t nmsg)
        struct ist pfx[4];
        size_t npfx = 0;
 
-       if (sink->fmt == SINK_FMT_SHORT) {
+       if (sink->fmt == SINK_FMT_SHORT || sink->fmt == SINK_FMT_TIMED) {
                short_hdr[0] = '<';
                short_hdr[1] = '0' + sink->syslog_minlvl;
                short_hdr[2] = '>';
@@ -159,6 +160,12 @@ ssize_t __sink_write(struct sink *sink, const struct ist msg[], size_t nmsg)
                npfx++;
         }
 
+       if (sink->fmt == SINK_FMT_ISO || sink->fmt == SINK_FMT_TIMED) {
+               pfx[npfx].ptr = timeofday_as_iso_us(1);
+               pfx[npfx].len = 27;
+               npfx++;
+        }
+
        if (sink->type == SINK_TYPE_FD) {
                return fd_write_frag_line(sink->ctx.fd, sink->maxlen, pfx, npfx, msg, nmsg, 1);
        }