summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/trace.h1
-rw-r--r--lib/zlog.c29
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/trace.h b/lib/trace.h
index dd6fb73ae..d605cad0c 100644
--- a/lib/trace.h
+++ b/lib/trace.h
@@ -107,6 +107,7 @@ THREAD_OPERATION_TRACEPOINT_INSTANCE(thread_call)
/* clang-format on */
#include <lttng/tracepoint-event.h>
+#include <lttng/tracelog.h>
#else /* HAVE_LTTNG */
diff --git a/lib/zlog.c b/lib/zlog.c
index 8dfd20371..f28ff0861 100644
--- a/lib/zlog.c
+++ b/lib/zlog.c
@@ -52,6 +52,7 @@
#include "printfrr.h"
#include "frrcu.h"
#include "zlog.h"
+#include "trace.h"
DEFINE_MTYPE_STATIC(LIB, LOG_MESSAGE, "log message")
DEFINE_MTYPE_STATIC(LIB, LOG_TLSBUF, "log thread-local buffer")
@@ -450,6 +451,34 @@ void vzlog(int prio, const char *fmt, va_list ap)
{
struct zlog_tls *zlog_tls = zlog_tls_get();
+#ifdef HAVE_LTTNG
+ va_list copy;
+ va_copy(copy, ap);
+ char *msg = vasprintfrr(MTYPE_LOG_MESSAGE, fmt, copy);
+
+ switch (prio) {
+ case LOG_ERR:
+ tracelog(TRACE_ERR, msg);
+ break;
+ case LOG_WARNING:
+ tracelog(TRACE_WARNING, msg);
+ break;
+ case LOG_DEBUG:
+ tracelog(TRACE_DEBUG, msg);
+ break;
+ case LOG_NOTICE:
+ tracelog(TRACE_DEBUG, msg);
+ break;
+ case LOG_INFO:
+ default:
+ tracelog(TRACE_INFO, msg);
+ break;
+ }
+
+ va_end(copy);
+ XFREE(MTYPE_LOG_MESSAGE, msg);
+#endif
+
if (zlog_tls)
vzlog_tls(zlog_tls, prio, fmt, ap);
else