diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2022-03-07 11:30:09 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2022-03-07 18:03:16 +0100 |
commit | 834585bdb98a162228399b9eec03b9a17e8d391e (patch) | |
tree | a7dd3fb09c44e9f83d30bb53e2232a88ed6da8fe /lib | |
parent | lib: support multiple `--log` options (diff) | |
download | frr-834585bdb98a162228399b9eec03b9a17e8d391e.tar.xz frr-834585bdb98a162228399b9eec03b9a17e8d391e.zip |
lib: add a few more bits to live log header
... and add some comments explaining the individual fields.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zlog_live.c | 23 | ||||
-rw-r--r-- | lib/zlog_live.h | 29 |
2 files changed, 47 insertions, 5 deletions
diff --git a/lib/zlog_live.c b/lib/zlog_live.c index 7abf1a801..fd2291a86 100644 --- a/lib/zlog_live.c +++ b/lib/zlog_live.c @@ -64,14 +64,16 @@ static void zlog_live(struct zlog_target *zt, struct zlog_msg *msgs[], for (i = 0; i < nmsgs; i++) { const struct fmt_outpos *argpos; - size_t n_argpos, arghdrlen; + size_t n_argpos, texthdrlen; struct zlog_msg *msg = msgs[i]; int prio = zlog_msg_prio(msg); + const struct xref_logmsg *xref; + intmax_t pid, tid; if (prio > zt->prio_min) continue; - zlog_msg_args(msg, &arghdrlen, &n_argpos, &argpos); + zlog_msg_args(msg, &texthdrlen, &n_argpos, &argpos); mmh->msg_hdr.msg_iov = iov; @@ -90,14 +92,27 @@ static void zlog_live(struct zlog_target *zt, struct zlog_msg *msgs[], iov++; zlog_msg_tsraw(msg, &ts); + zlog_msg_pid(msg, &pid, &tid); + xref = zlog_msg_xref(msg); hdr->ts_sec = ts.tv_sec; hdr->ts_nsec = ts.tv_nsec; - hdr->prio = zlog_msg_prio(msg); + hdr->pid = pid; + hdr->tid = tid; + hdr->prio = prio; hdr->flags = 0; hdr->textlen = textlen; - hdr->arghdrlen = arghdrlen; + hdr->texthdrlen = texthdrlen; hdr->n_argpos = n_argpos; + if (xref) { + memcpy(hdr->uid, xref->xref.xrefdata->uid, + sizeof(hdr->uid)); + hdr->ec = xref->ec; + } else { + memset(hdr->uid, 0, sizeof(hdr->uid)); + hdr->ec = 0; + } + hdr->hdrlen = sizeof(*hdr) + sizeof(*argpos) * n_argpos; mmh->msg_hdr.msg_iovlen = iov - mmh->msg_hdr.msg_iov; mmh++; diff --git a/lib/zlog_live.h b/lib/zlog_live.h index c948baeab..5e80f016f 100644 --- a/lib/zlog_live.h +++ b/lib/zlog_live.h @@ -20,13 +20,40 @@ #include "printfrr.h" struct zlog_live_hdr { + /* timestamp (CLOCK_REALTIME) */ uint64_t ts_sec; uint32_t ts_nsec; + + /* length of zlog_live_hdr, including variable length bits and + * possible future extensions - aka start of text + */ + uint32_t hdrlen; + + /* process & thread ID, meaning depends on OS */ + int64_t pid; + int64_t tid; + + /* syslog priority value */ uint32_t prio; + /* flags: currently unused */ uint32_t flags; + /* length of message text - extra data (e.g. future key/value metadata) + * may follow after it + */ uint32_t textlen; + /* length of "[XXXXX-XXXXX][EC 0] " header; consumer may want to skip + * over it if using the raw values below. Note that this text may be + * absent depending on "log error-category" and "log unique-id" + * settings + */ + uint32_t texthdrlen; + + /* xref unique identifier, "XXXXX-XXXXX\0" = 12 bytes */ + char uid[12]; + /* EC value */ + uint32_t ec; - uint32_t arghdrlen; + /* recorded printf formatting argument positions (variable length) */ uint32_t n_argpos; struct fmt_outpos argpos[0]; }; |