summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEmanuele Di Pascale <emanuele@voltanet.io>2019-01-25 14:40:27 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2019-02-05 20:55:04 +0100
commit77d9c92609c919fa889a2d7292ec40b8cbdcff77 (patch)
treea37c9a72b197d512f935b8c6e7fbbe7b5dc687f3 /lib
parentMerge pull request #3693 from chiragshah6/ospf_vrf_dev (diff)
downloadfrr-77d9c92609c919fa889a2d7292ec40b8cbdcff77.tar.xz
frr-77d9c92609c919fa889a2d7292ec40b8cbdcff77.zip
lib: add hooks for external logging function
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/log.c8
-rw-r--r--lib/log.h6
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/log.c b/lib/log.c
index 12a1d7fbe..f93695761 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -29,6 +29,7 @@
#include "memory.h"
#include "command.h"
#include "lib_errors.h"
+#include "lib/hook.h"
#ifndef SUNOS_5
#include <sys/un.h>
@@ -46,6 +47,10 @@
DEFINE_MTYPE_STATIC(LIB, ZLOG, "Logging")
+/* hook for external logging */
+DEFINE_HOOK(zebra_ext_log, (int priority, const char *format, va_list args),
+ (priority, format, args));
+
static int logfile_fd = -1; /* Used in signal handler. */
struct zlog *zlog_default = NULL;
@@ -213,6 +218,9 @@ void vzlog(int priority, const char *format, va_list args)
tsctl.already_rendered = 0;
struct zlog *zl = zlog_default;
+ /* call external hook */
+ hook_call(zebra_ext_log, priority, format, args);
+
/* When zlog_default is also NULL, use stderr for logging. */
if (zl == NULL) {
tsctl.precision = 0;
diff --git a/lib/log.h b/lib/log.h
index be1d9fb59..8fb98a02a 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -26,6 +26,12 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
+#include <stdarg.h>
+#include "lib/hook.h"
+
+/* Hook for external logging function */
+DECLARE_HOOK(zebra_ext_log, (int priority, const char *format, va_list args),
+ (priority, format, args));
/* Here is some guidance on logging levels to use:
*