From 2298b92f1832a893b2e9a8eb193c219e2221174b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 22 Nov 2023 17:18:29 +0100 Subject: [PATCH] lib/util: convert DBG_STARTUP_NOTICE() to use debug_set_forced_log_priority(DBGLVL_NOTICE) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Using -1 as log level is not compatible without our infrastructure. As all backends are initialized with .log_level = -1, which means they don't log the message, but now they all try to handle the startup message even if they are not configured. E.g. is means that systemd's journalctl get the message twice now, first via the syslog and also the systemd backend. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Stefan Metzmacher Reviewed-by: Björn Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit cd8dcff9e9cbfffab8c502c8701c00b0c8e3512b) --- lib/util/debug.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/util/debug.h b/lib/util/debug.h index b62f2d19bcc..d4bd8246b97 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -269,14 +269,18 @@ void debuglevel_set_class(size_t idx, int level); /* * Debug levels matching RFC 3164 */ -#define DBGLVL_STARTUP_NOTICE -1 /* startup notice */ #define DBGLVL_ERR 0 /* error conditions */ #define DBGLVL_WARNING 1 /* warning conditions */ #define DBGLVL_NOTICE 3 /* normal, but significant, condition */ #define DBGLVL_INFO 5 /* informational message */ #define DBGLVL_DEBUG 10 /* debug-level message */ -#define DBG_STARTUP_NOTICE(...) DBG_PREFIX(DBGLVL_STARTUP_NOTICE, (__VA_ARGS__)) +#define DBG_STARTUP_NOTICE(...) do { \ + debug_set_forced_log_priority(DBGLVL_NOTICE); \ + D_ERR(__VA_ARGS__); \ + debug_set_forced_log_priority(-1); \ +} while(0) + #define DBG_ERR(...) DBG_PREFIX(DBGLVL_ERR, (__VA_ARGS__)) #define DBG_WARNING(...) DBG_PREFIX(DBGLVL_WARNING, (__VA_ARGS__)) #define DBG_NOTICE(...) DBG_PREFIX(DBGLVL_NOTICE, (__VA_ARGS__)) -- 2.34.1