From: Vincent Bernat Date: Sat, 16 May 2015 05:57:41 +0000 (+0200) Subject: lldpcli: ensure we also display logs from liblldpctl X-Git-Tag: 0.7.15~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=082c03a94583d55c67f3b5bc7d0b9d7567eb0294;p=thirdparty%2Flldpd.git lldpcli: ensure we also display logs from liblldpctl --- diff --git a/src/client/lldpcli.c b/src/client/lldpcli.c index 7a852a1b..98d4267f 100644 --- a/src/client/lldpcli.c +++ b/src/client/lldpcli.c @@ -31,6 +31,7 @@ #include #include #include +#include #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);