From 966799385e80375aa8e8b87aa68dffa6dc11d17e Mon Sep 17 00:00:00 2001 From: GalaxyGorilla Date: Tue, 15 Oct 2019 11:15:22 +0000 Subject: [PATCH] lib: Let libyang log everything possible Currently libyang logs errors only (LY_LLERR by default), independent of FRR's log level. This commit lets libyang log everything including all sorts of debug logs (when libyang is built in 'Debug' mode). FRR's logging infrastructure filters logs out according to the configured log level. There is a very small performance overhead involved, even when libyang is build in 'Release' mode. This overhead is mainly affecting config processing and barely measurable being around 0-3% of the processing time without this change. Signed-off-by: Sascha Kattelmann --- lib/yang.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/yang.c b/lib/yang.c index 674f3610d6..5470762ea6 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -595,7 +595,7 @@ struct yang_data *yang_data_list_find(const struct list *list, /* Make libyang log its errors using FRR logging infrastructure. */ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path) { - int priority; + int priority = LOG_ERR; switch (level) { case LY_LLERR: @@ -605,10 +605,9 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path) priority = LOG_WARNING; break; case LY_LLVRB: + case LY_LLDBG: priority = LOG_DEBUG; break; - default: - return; } if (path) @@ -646,6 +645,10 @@ void yang_init(void) ly_set_log_clb(ly_log_cb, 1); ly_log_options(LY_LOLOG | LY_LOSTORE); + /* Let libyang log everything possible. */ + ly_verb(LY_LLDBG); + ly_verb_dbg(0xFF); + /* Initialize libyang container for native models. */ ly_native_ctx = yang_ctx_new_setup(); if (!ly_native_ctx) { -- 2.39.5