]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add a few more bits to live log header
authorDavid Lamparter <equinox@opensourcerouting.org>
Mon, 7 Mar 2022 10:30:09 +0000 (11:30 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 7 Mar 2022 17:03:16 +0000 (18:03 +0100)
... and add some comments explaining the individual fields.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/zlog_live.c
lib/zlog_live.h
vtysh/vtysh.c

index 7abf1a801a9459880568e8dd10a630e10898bac9..fd2291a86f84f3fc38938ec208a01484aef8d936 100644 (file)
@@ -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++;
index c948baeab1b9f42c27c46fc86ecf44b6aa91dbcc..5e80f016fdfb7aa274ab784db780465415386d73 100644 (file)
 #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];
 };
index f8c6a1fc1d4427b08f1ca5ce8b56468a55459fd4..ed008bd089a4c27e730a464edfa8d317e0716ce7 100644 (file)
@@ -3677,7 +3677,7 @@ static void vtysh_log_read(struct thread *thread)
                buf.hdr.ts_nsec = ts.tv_nsec;
                buf.hdr.prio = LOG_ERR;
                buf.hdr.flags = 0;
-               buf.hdr.arghdrlen = 0;
+               buf.hdr.texthdrlen = 0;
                buf.hdr.n_argpos = 0;
        }