Blame SOURCES/0008-Log-change-sbd-s-default-logging-level-to-LOG_NOTICE.patch

6f8c14
From 1d8fd2540ccf254d90e831f612415226043fc5b3 Mon Sep 17 00:00:00 2001
6f8c14
From: "Gao,Yan" <ygao@suse.com>
6f8c14
Date: Fri, 27 Apr 2018 13:41:00 +0200
6f8c14
Subject: [PATCH] Log: change sbd's default logging level to LOG_NOTICE
6f8c14
6f8c14
With the refactoring of logging parts and 1ee3503c, sbd became too
6f8c14
silent given the default logging level LOG_WARNING, even under the
6f8c14
situations where it's supposed to tell something.
6f8c14
6f8c14
This commit changes sbd's default logging level to LOG_NOTICE.
6f8c14
Meanwhile pacemaker library's logging level remains at LOG_WARNING.
6f8c14
With "-v", sbd's logging level is set to LOG_INFO.
6f8c14
With "-vv", sbd's logging level is set to LOG_DEBUG.
6f8c14
With "-vvv", both sbd's and pacemaker library's logging levels are set
6f8c14
to LOG_DEBUG.
6f8c14
---
6f8c14
 src/sbd-inquisitor.c | 28 ++++++++++++++++++++++------
6f8c14
 1 file changed, 22 insertions(+), 6 deletions(-)
6f8c14
6f8c14
diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c
6f8c14
index 59408b3..237bf43 100644
6f8c14
--- a/src/sbd-inquisitor.c
6f8c14
+++ b/src/sbd-inquisitor.c
6f8c14
@@ -803,6 +803,19 @@ parse_device_line(const char *line)
6f8c14
     return found;
6f8c14
 }
6f8c14
 
6f8c14
+#define SBD_SOURCE_FILES "sbd-cluster.c,sbd-common.c,sbd-inquisitor.c,sbd-md.c,sbd-pacemaker.c,setproctitle.c"
6f8c14
+
6f8c14
+static void
6f8c14
+sbd_log_filter_ctl(const char *files, uint8_t priority)
6f8c14
+{
6f8c14
+	if (files == NULL) {
6f8c14
+		files = SBD_SOURCE_FILES;
6f8c14
+	}
6f8c14
+
6f8c14
+	qb_log_filter_ctl(QB_LOG_SYSLOG, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, files, priority);
6f8c14
+	qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, files, priority);
6f8c14
+}
6f8c14
+
6f8c14
 int
6f8c14
 arg_enabled(int arg_count)
6f8c14
 {
6f8c14
@@ -834,6 +847,7 @@ int main(int argc, char **argv, char **envp)
6f8c14
 
6f8c14
         qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_TRUE);
6f8c14
         qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_FALSE);
6f8c14
+        sbd_log_filter_ctl(NULL, LOG_NOTICE);
6f8c14
 
6f8c14
 	sbd_get_uname();
6f8c14
 
6f8c14
@@ -926,15 +940,17 @@ int main(int argc, char **argv, char **envp)
6f8c14
 		case 'v':
6f8c14
                     debug++;
6f8c14
                     if(debug == 1) {
6f8c14
-                        qb_log_filter_ctl(QB_LOG_SYSLOG, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "sbd-common.c,sbd-inquisitor.c,sbd-md.c,sbd-pacemaker.c", LOG_DEBUG);
6f8c14
-                        qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "sbd-common.c,sbd-inquisitor.c,sbd-md.c,sbd-pacemaker.c", LOG_DEBUG);
6f8c14
-			cl_log(LOG_INFO, "Verbose mode enabled.");
6f8c14
+                        sbd_log_filter_ctl(NULL, LOG_INFO);
6f8c14
+                        cl_log(LOG_INFO, "Verbose mode enabled.");
6f8c14
 
6f8c14
                     } else if(debug == 2) {
6f8c14
+                        sbd_log_filter_ctl(NULL, LOG_DEBUG);
6f8c14
+                        cl_log(LOG_INFO, "Debug mode enabled.");
6f8c14
+
6f8c14
+                    } else if(debug == 3) {
6f8c14
                         /* Go nuts, turn on pacemaker's logging too */
6f8c14
-                        qb_log_filter_ctl(QB_LOG_SYSLOG, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
6f8c14
-                        qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
6f8c14
-			cl_log(LOG_INFO, "Verbose library mode enabled.");
6f8c14
+                        sbd_log_filter_ctl("*", LOG_DEBUG);
6f8c14
+                        cl_log(LOG_INFO, "Debug library mode enabled.");
6f8c14
                     }
6f8c14
                     break;
6f8c14
 		case 'T':
6f8c14
-- 
6f8c14
1.8.3.1
6f8c14