From 071377f9cedafbbbadb1e28daf14c2df630f42a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 9 Apr 2024 20:32:08 +0200 Subject: [PATCH 1/3] logging: remove dead code This second logging callback is never set. Fixes: 0553277 log FEATURE supply session as log clb parameter --- src/log.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/log.c b/src/log.c index 8838ec2e..dcc3ca5d 100644 --- a/src/log.c +++ b/src/log.c @@ -35,7 +35,6 @@ */ ATOMIC_T verbose_level = 0; -void (*depr_print_clb)(NC_VERB_LEVEL level, const char *msg); void (*print_clb)(const struct nc_session *session, NC_VERB_LEVEL level, const char *msg); API void @@ -103,8 +102,6 @@ prv_vprintf(const struct nc_session *session, NC_VERB_LEVEL level, const char *f if (print_clb) { print_clb(session, level, prv_msg); - } else if (depr_print_clb) { - depr_print_clb(level, prv_msg); } else if (session && session->id) { fprintf(stderr, "Session %u %s: %s\n", session->id, verb[level].label, prv_msg); } else { @@ -132,8 +129,6 @@ nc_ly_log_clb(LY_LOG_LEVEL lvl, const char *msg, const char *UNUSED(data_path), { if (print_clb) { print_clb(NULL, (NC_VERB_LEVEL)lvl, msg); - } else if (depr_print_clb) { - depr_print_clb((NC_VERB_LEVEL)lvl, msg); } } @@ -141,6 +136,5 @@ API void nc_set_print_clb_session(void (*clb)(const struct nc_session *, NC_VERB_LEVEL, const char *)) { print_clb = clb; - depr_print_clb = NULL; ly_set_log_clb(nc_ly_log_clb); } From 43975f40dc2707364503b42f8e0ca26f9519d9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 9 Apr 2024 20:35:05 +0200 Subject: [PATCH 2/3] docs: `nc_set_print_clb_session` is not per-session Bug: https://github.com/CESNET/libnetconf2/issues/476 --- src/log.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/log.h b/src/log.h index 8564db13..368a3eff 100644 --- a/src/log.h +++ b/src/log.h @@ -76,6 +76,8 @@ void nc_libssh_thread_verbosity(int level); * * This callback is set for libnetconf2 and also libyang that is used internally. libyang * callback can be set explicitly, but must be done so after calling this function. + * The callback is not set per-session, it is a global resource. It might be called with + * a NULL session parameter. * * @param[in] clb Callback that is called for every message. */ From 32a399bc05cb4af39ca17b9c4c975efdb62d3f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 9 Apr 2024 20:36:46 +0200 Subject: [PATCH 3/3] log: do not set libyang's logging callback Bug: https://github.com/CESNET/libnetconf2/issues/476 --- src/log.c | 10 ---------- src/log.h | 2 -- 2 files changed, 12 deletions(-) diff --git a/src/log.c b/src/log.c index dcc3ca5d..1a6dd805 100644 --- a/src/log.c +++ b/src/log.c @@ -123,18 +123,8 @@ prv_printf(const struct nc_session *session, NC_VERB_LEVEL level, const char *fo va_end(ap); } -static void -nc_ly_log_clb(LY_LOG_LEVEL lvl, const char *msg, const char *UNUSED(data_path), const char *UNUSED(schema_path), - uint64_t UNUSED(line)) -{ - if (print_clb) { - print_clb(NULL, (NC_VERB_LEVEL)lvl, msg); - } -} - API void nc_set_print_clb_session(void (*clb)(const struct nc_session *, NC_VERB_LEVEL, const char *)) { print_clb = clb; - ly_set_log_clb(nc_ly_log_clb); } diff --git a/src/log.h b/src/log.h index 368a3eff..b4365ccc 100644 --- a/src/log.h +++ b/src/log.h @@ -74,8 +74,6 @@ void nc_libssh_thread_verbosity(int level); /** * @brief Set libnetconf print callback. * - * This callback is set for libnetconf2 and also libyang that is used internally. libyang - * callback can be set explicitly, but must be done so after calling this function. * The callback is not set per-session, it is a global resource. It might be called with * a NULL session parameter. *