]> 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)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 5 Feb 2019 19:55:04 +0000 (20:55 +0100)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
lib/log.c
lib/log.h

index 12a1d7fbe04062a1c8ae24863c568a8ea00b2878..f936957611330bcddf25068959a24a5fdf5236ce 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;
@@ -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;
index be1d9fb5922896b083a2009a4f2fb577a833b5b3..8fb98a02aba84d6ab426e48f9972b8333a005d94 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:
  *