From: Willy Tarreau Date: Thu, 26 Sep 2019 06:03:58 +0000 (+0200) Subject: MINOR: sink: finally implement support for SINK_FMT_{TIMED,ISO} X-Git-Tag: v2.1-dev2~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53ba9d9bcf48d0a9d3474cbd7adfb7fcfe03a314;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/sink.c b/src/sink.c index bd06f1ebbe..e2270b156b 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); }