From 1ae9eedc1a564fd772a3c2432b0886d10398862c Mon Sep 17 00:00:00 2001
From: Tim Wickberg <tim@schedmd.com>
Date: Tue, 24 Mar 2020 01:39:49 -0600
Subject: [PATCH] Change log_flag() to log at verbose level and prepend flag
 name.

Logging at the verbose() level keeps messages out of the user commands
by default (unless -v was requested), which minimizes disruption from
adding additional debugging messages in to the network and RPC layers.

Prepending the debug flag helps identify which messages have been enabled
by a given flag, which is useful when tracing a given subsystem. A log of
associated messages have given hints to this, but making this consistent
with associated cleanup (to come) should simplify tracing when necessary.

Bug 8227.
---
 RELEASE_NOTES             | 3 +++
 doc/man/man5/slurm.conf.5 | 6 +++---
 src/common/log.h          | 3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 8ce848ded70..8f426d93894 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -30,6 +30,9 @@ HIGHLIGHTS
  -- The example systemd unit files have been changed to the "simple" type of
     operation, and the daemon will now run in the foreground within systemd
     instead of daemonizing itself.
+ -- Log messages enabled by the various DebugFlags have been overhauled, and
+    will all print at the verbose() level, and prepend the flag name that is
+    associated with a given log message.
 
 CONFIGURATION FILE CHANGES (see man appropriate man page for details)
 =====================================================================
diff --git a/doc/man/man5/slurm.conf.5 b/doc/man/man5/slurm.conf.5
index 6958af8d76c..52555e67f43 100644
--- a/doc/man/man5/slurm.conf.5
+++ b/doc/man/man5/slurm.conf.5
@@ -551,9 +551,9 @@ The default value is "cred/munge" and is the recommended.
 \fBDebugFlags\fR
 Defines specific subsystems which should provide more detailed event logging.
 Multiple subsystems can be specified with comma separators.
-Most DebugFlags will result in verbose logging for the identified subsystems
-and could impact performance.
-Valid subsystems available today (with more to come) include:
+Most DebugFlags will result in verbose-level logging for the identified
+subsystems, and could impact performance.
+Valid subsystems available include:
 .RS
 .TP 17
 \fBAccrue\fR
diff --git a/src/common/log.h b/src/common/log.h
index 5816512ba0a..39316b959be 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -338,7 +338,8 @@ void spank_log(const char *, ...) __attribute__ ((format (printf, 1, 2)));
 #define log_flag(flag, fmt, ...)					\
 	do {								\
 		if (slurmctld_conf.debug_flags & DEBUG_FLAG_##flag)	\
-			log_var(LOG_LEVEL_INFO, fmt, ##__VA_ARGS__);	\
+			log_var(LOG_LEVEL_VERBOSE, #flag ": " fmt,	\
+				##__VA_ARGS__);				\
 	} while (0)
 
 #endif /* !_LOG_H */
-- 
GitLab