summaryrefslogtreecommitdiffstats
path: root/lib/zlog.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2020-04-28 09:30:59 +0200
committerDavid Lamparter <equinox@diac24.net>2021-02-01 17:28:09 +0100
commit131879fb926798bfefd80b0e2cba266919c5be1d (patch)
treed3969846271acbdc3f2cdb9161f813b1353f4988 /lib/zlog.c
parentlib/xref: use to transport thread_* file/line/func (diff)
downloadfrr-131879fb926798bfefd80b0e2cba266919c5be1d.tar.xz
frr-131879fb926798bfefd80b0e2cba266919c5be1d.zip
lib/xref: add xrefs on zlog_* calls
This allows extracting a list of all log messages including their ECs and autogenerated unique IDs for them. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/zlog.c')
-rw-r--r--lib/zlog.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/zlog.c b/lib/zlog.c
index e77feec5f..51509e24f 100644
--- a/lib/zlog.c
+++ b/lib/zlog.c
@@ -94,6 +94,7 @@ struct zlog_msg {
const char *fmt;
va_list args;
+ const struct xref_logmsg *xref;
char *stackbuf;
size_t stackbufsz;
@@ -349,12 +350,14 @@ void zlog_tls_buffer_flush(void)
}
-static void vzlog_notls(int prio, const char *fmt, va_list ap)
+static void vzlog_notls(const struct xref_logmsg *xref, int prio,
+ const char *fmt, va_list ap)
{
struct zlog_target *zt;
struct zlog_msg stackmsg = {
.prio = prio & LOG_PRIMASK,
.fmt = fmt,
+ .xref = xref,
}, *msg = &stackmsg;
char stackbuf[512];
@@ -379,8 +382,8 @@ static void vzlog_notls(int prio, const char *fmt, va_list ap)
XFREE(MTYPE_LOG_MESSAGE, msg->text);
}
-static void vzlog_tls(struct zlog_tls *zlog_tls, int prio,
- const char *fmt, va_list ap)
+static void vzlog_tls(struct zlog_tls *zlog_tls, const struct xref_logmsg *xref,
+ int prio, const char *fmt, va_list ap)
{
struct zlog_target *zt;
struct zlog_msg *msg;
@@ -413,6 +416,7 @@ static void vzlog_tls(struct zlog_tls *zlog_tls, int prio,
msg->stackbufsz = TLS_LOG_BUF_SIZE - zlog_tls->bufpos - 1;
msg->fmt = fmt;
msg->prio = prio & LOG_PRIMASK;
+ msg->xref = xref;
if (msg->prio < LOG_INFO)
immediate = true;
@@ -447,7 +451,8 @@ static void vzlog_tls(struct zlog_tls *zlog_tls, int prio,
XFREE(MTYPE_LOG_MESSAGE, msg->text);
}
-void vzlog(int prio, const char *fmt, va_list ap)
+void vzlogx(const struct xref_logmsg *xref, int prio,
+ const char *fmt, va_list ap)
{
struct zlog_tls *zlog_tls = zlog_tls_get();
@@ -480,9 +485,9 @@ void vzlog(int prio, const char *fmt, va_list ap)
#endif
if (zlog_tls)
- vzlog_tls(zlog_tls, prio, fmt, ap);
+ vzlog_tls(zlog_tls, xref, prio, fmt, ap);
else
- vzlog_notls(prio, fmt, ap);
+ vzlog_notls(xref, prio, fmt, ap);
}
void zlog_sigsafe(const char *text, size_t len)
@@ -516,6 +521,11 @@ int zlog_msg_prio(struct zlog_msg *msg)
return msg->prio;
}
+const struct xref_logmsg *zlog_msg_xref(struct zlog_msg *msg)
+{
+ return msg->xref;
+}
+
const char *zlog_msg_text(struct zlog_msg *msg, size_t *textlen)
{
if (!msg->text) {