From 53ba9d9bcf48d0a9d3474cbd7adfb7fcfe03a314 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 26 Sep 2019 08:03:58 +0200 Subject: [PATCH] MINOR: sink: finally implement support for SINK_FMT_{TIMED,ISO} These formats add the date with a resolution of the microsecond before the message fields. --- src/sink.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sink.c b/src/sink.c index bd06f1ebb..e2270b156 100644 --- a/src/sink.c +++ b/src/sink.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -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); }