]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add hooks for external logging function
authorEmanuele Di Pascale <emanuele@voltanet.io>
Fri, 25 Jan 2019 13:40:27 +0000 (14:40 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 6 Feb 2019 09:20:29 +0000 (10:20 +0100)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
lib/log.c
lib/log.h

index 1619ad36ec4b883e843f7bff1d76f92596571cf2..6c468f5e2d7f4398027910bf1ab4460ad26cb44d 100644 (file)
--- 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>
 
 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;
@@ -207,6 +212,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;
index 7b21a0ce37716475490a8e295eca50c9fa1baaa6..0551c0ebc3deeaaacc535611818f4d98e545fbe0 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
 #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:
  *