]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: ensure we also display logs from liblldpctl
authorVincent Bernat <vincent@bernat.im>
Sat, 16 May 2015 05:57:41 +0000 (07:57 +0200)
committerVincent Bernat <vincent@bernat.im>
Sat, 16 May 2015 05:57:41 +0000 (07:57 +0200)
src/client/lldpcli.c

index 7a852a1b2bc09eeb026306abb3681ec91926ce3c..98d4267fed1a046abb56c21df100b595510b2961 100644 (file)
@@ -31,6 +31,7 @@
 #include <dirent.h>
 #include <signal.h>
 #include <sys/queue.h>
+#include <syslog.h>
 
 #include "client.h"
 
@@ -44,6 +45,18 @@ extern const char    *__progname;
 static struct cmd_node *root = NULL;
 const char *ctlname = NULL;
 
+static void
+log_from_lib(int severity, const char *msg)
+{
+       switch (severity) {
+       case LOG_DEBUG: log_debug("liblldpctl", "%s", msg); break;
+       case LOG_INFO:
+       case LOG_NOTICE: log_info("liblldpctl", "%s", msg); break;
+       default:
+               log_warnx("liblldpctl", "%s", msg); break;
+       }
+}
+
 static int
 is_lldpctl(const char *name)
 {
@@ -485,6 +498,9 @@ main(int argc, char *argv[])
        /* Register commands */
        root = register_commands();
 
+       /* Initialize logging for liblldpctl */
+       lldpctl_log_callback(log_from_lib);
+
        /* Make a connection */
        log_debug("lldpctl", "connect to lldpd");
        conn = lldpctl_new_name(ctlname, NULL, NULL, NULL);