[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Fri Nov 24 10:35:02 UTC 2023


The branch, master has been updated
       via  f5c76c3c814 Revert "README.Coding.md: add DBG_STARTUP_NOTICE macro"
       via  cd8dcff9e9c lib/util: convert DBG_STARTUP_NOTICE() to use debug_set_forced_log_priority(DBGLVL_NOTICE)
       via  bd21a0cdefb lib/util: add debug_set_forced_log_priority()
      from  83e8971c0f1 Claims initial black box tests

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f5c76c3c814dac2b0c09026520f75c0b0e22b6b4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 23 13:20:23 2023 +0100

    Revert "README.Coding.md: add DBG_STARTUP_NOTICE macro"
    
    This reverts commit bb370b9381e5d223ff4ac62f612888f90a63fcc5.
    
    We no longer use log level -1
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Björn Jacke <bjacke at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Nov 24 10:34:58 UTC 2023 on atb-devel-224

commit cd8dcff9e9cbfffab8c502c8701c00b0c8e3512b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 22 17:18:29 2023 +0100

    lib/util: convert DBG_STARTUP_NOTICE() to use debug_set_forced_log_priority(DBGLVL_NOTICE)
    
    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 <metze at samba.org>
    Reviewed-by: Björn Jacke <bjacke at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bd21a0cdefb30ef5522f81d865c03d11a182a63c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 22 17:03:30 2023 +0100

    lib/util: add debug_set_forced_log_priority()
    
    By default the priority for syslog/systemd is derived from
    the log level of the debug message.
    
    But for things like startup messages we want to
    change the priority temporary, like this:
    
    debug_set_forced_log_priority(DBGLVL_NOTICE);
    D_ERR("Startup...\n");
    debug_set_forced_log_priority(-1);
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Björn Jacke <bjacke at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 README.Coding.md | 11 +++++------
 lib/util/debug.c | 10 ++++++++++
 lib/util/debug.h |  9 +++++++--
 3 files changed, 22 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/README.Coding.md b/README.Coding.md
index 132f3f4fa58..76f2c70e95a 100644
--- a/README.Coding.md
+++ b/README.Coding.md
@@ -539,12 +539,11 @@ It should be:
 Use these following macros instead of DEBUG:
 
 ```
-DBG_STARTUP_NOTICE  log level -1	startup like notice
-DBG_ERR             log level 0		error conditions
-DBG_WARNING         log level 1		warning conditions
-DBG_NOTICE          log level 3		normal, but significant, condition
-DBG_INFO            log level 5		informational message
-DBG_DEBUG           log level 10	debug-level message
+DBG_ERR         log level 0		error conditions
+DBG_WARNING     log level 1		warning conditions
+DBG_NOTICE      log level 3		normal, but significant, condition
+DBG_INFO        log level 5		informational message
+DBG_DEBUG       log level 10		debug-level message
 ```
 
 Example usage:
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 6872f2dfe46..f1f91ebe7a7 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -94,6 +94,7 @@ static struct {
 	char hostname[HOST_NAME_MAX+1];
 	bool reopening_logs;
 	bool schedule_reopen_logs;
+	int forced_log_priority;
 
 	struct debug_settings settings;
 	debug_callback_fn callback;
@@ -230,6 +231,10 @@ static int debug_level_to_priority(int level)
 	};
 	int priority;
 
+	if (state.forced_log_priority != -1) {
+		level = state.forced_log_priority;
+	}
+
 	if (level < 0 || (size_t)level >= ARRAY_SIZE(priority_map))
 		priority = LOG_DEBUG;
 	else
@@ -1133,6 +1138,11 @@ void debug_set_hostname(const char *name)
 	strlcpy(state.hostname, name, sizeof(state.hostname));
 }
 
+void debug_set_forced_log_priority(int forced_log_priority)
+{
+	state.forced_log_priority = forced_log_priority;
+}
+
 /**
  * Ensure debug logs are initialised.
  *
diff --git a/lib/util/debug.h b/lib/util/debug.h
index 90230a2d88f..4687ac074b1 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__))
@@ -356,6 +360,7 @@ void debug_set_settings(struct debug_settings *settings,
 			const char *logging_param,
 			int syslog_level, bool syslog_only);
 void debug_set_hostname(const char *name);
+void debug_set_forced_log_priority(int forced_log_priority);
 bool reopen_logs_internal( void );
 void force_check_log_size( void );
 bool need_to_check_log_size( void );


-- 
Samba Shared Repository



More information about the samba-cvs mailing list