And remove the previous commit, use internal logging instead.
#include <dirent.h>
#include <signal.h>
#include <sys/queue.h>
-#include <syslog.h>
#include "client.h"
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)
{
}
}
log_init(debug, __progname);
+ lldpctl_log_level(debug);
/* Get and parse command line options */
optind = 1;
/* 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);
atoms/config.c atoms/dot1.c atoms/dot3.c \
atoms/interface.c atoms/med.c atoms/mgmt.c atoms/port.c
liblldpctl_la_LIBADD = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoint.la
-liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -export-symbols-regex '^lldpctl_' -version-info 9:0:5
+liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -export-symbols-regex '^lldpctl_' -version-info 10:0:6
# -version-info format is `current`:`revision`:`age`. For more details, see:
# http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91
{
log_register(cb);
}
+
+void
+lldpctl_log_level(int level)
+{
+ log_level(level);
+}
*/
void lldpctl_log_callback(void (*cb)(int severity, const char *msg));
+/**
+ * Setup log level.
+ *
+ * By default, liblldpctl will only log warnings. The following function allows
+ * to increase verbosity. This function has no effect if callbacks are
+ * registered with the previous function.
+ *
+ * @param level Level of verbosity (1 = warnings, 2 = info, 3 = debug).
+ */
+void lldpctl_log_level(int level);
+
/**
* Possible error codes for functions that return negative integers on
* this purpose or for @c lldpctl_last_error().
tzset();
}
+void
+log_level(int n_debug)
+{
+ if (debug > 0 && n_debug >= 1)
+ debug = n_debug;
+}
+
void
log_register(void (*cb)(int, const char*))
{
void log_register(void (*cb)(int, const char*));
void log_accept(const char *);
+void log_level(int);
#endif