mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
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.
This commit is contained in:
parent
93acfa2263
commit
53ba9d9bcf
@ -22,6 +22,7 @@
|
|||||||
#include <common/config.h>
|
#include <common/config.h>
|
||||||
#include <common/ist.h>
|
#include <common/ist.h>
|
||||||
#include <common/mini-clist.h>
|
#include <common/mini-clist.h>
|
||||||
|
#include <common/time.h>
|
||||||
#include <proto/cli.h>
|
#include <proto/cli.h>
|
||||||
#include <proto/log.h>
|
#include <proto/log.h>
|
||||||
#include <proto/ring.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];
|
struct ist pfx[4];
|
||||||
size_t npfx = 0;
|
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[0] = '<';
|
||||||
short_hdr[1] = '0' + sink->syslog_minlvl;
|
short_hdr[1] = '0' + sink->syslog_minlvl;
|
||||||
short_hdr[2] = '>';
|
short_hdr[2] = '>';
|
||||||
@ -159,6 +160,12 @@ ssize_t __sink_write(struct sink *sink, const struct ist msg[], size_t nmsg)
|
|||||||
npfx++;
|
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) {
|
if (sink->type == SINK_TYPE_FD) {
|
||||||
return fd_write_frag_line(sink->ctx.fd, sink->maxlen, pfx, npfx, msg, nmsg, 1);
|
return fd_write_frag_line(sink->ctx.fd, sink->maxlen, pfx, npfx, msg, nmsg, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user