[PATCH 1/2] Add support for debug level trace in config file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 conf/lenses/corosync.aug  |    2 +-
 exec/logconfig.c          |   10 ++++++++--
 exec/logsys.c             |   20 +++++++++++++++-----
 include/corosync/logsys.h |    8 ++++++++
 man/corosync.conf.5       |    3 ++-
 5 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/conf/lenses/corosync.aug b/conf/lenses/corosync.aug
index 1f0b054..98cd268 100644
--- a/conf/lenses/corosync.aug
+++ b/conf/lenses/corosync.aug
@@ -83,7 +83,7 @@ let common_logging =
    kv "to_syslog" /yes|no|on|off/
    |kv "to_stderr" /yes|no|on|off/
    |kv "to_logfile" /yes|no|on|off/
-   |kv "debug" /yes|no|on|off/
+   |kv "debug" /yes|no|on|off|trace/
    |kv "logfile_priority" /alert|crit|debug|emerg|err|info|notice|warning/
    |kv "syslog_priority" /alert|crit|debug|emerg|err|info|notice|warning/
    |kv "syslog_facility" /daemon|local0|local1|local2|local3|local4|local5|local6|local7/
diff --git a/exec/logconfig.c b/exec/logconfig.c
index 3608233..cbfb7ee 100644
--- a/exec/logconfig.c
+++ b/exec/logconfig.c
@@ -417,14 +417,20 @@ static int corosync_main_config_set (
 
 	snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "debug");
 	if (map_get_string(key_name, &value) == CS_OK) {
+		if (strcmp (value, "trace") == 0) {
+			if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_TRACE) < 0) {
+				error_reason = "unable to set debug trace";
+				goto parse_error;
+			}
+		} else
 		if (strcmp (value, "on") == 0) {
-			if (logsys_config_debug_set (subsys, 1) < 0) {
+			if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_ON) < 0) {
 				error_reason = "unable to set debug on";
 				goto parse_error;
 			}
 		} else
 		if (strcmp (value, "off") == 0) {
-			if (logsys_config_debug_set (subsys, 0) < 0) {
+			if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_OFF) < 0) {
 				error_reason = "unable to set debug off";
 				goto parse_error;
 			}
diff --git a/exec/logsys.c b/exec/logsys.c
index c7a3b8b..3b94419 100644
--- a/exec/logsys.c
+++ b/exec/logsys.c
@@ -88,7 +88,7 @@ struct logsys_logger {
 	char subsys[LOGSYS_MAX_SUBSYS_NAMELEN];	/* subsystem name */
 	char *logfile;				/* log to file */
 	unsigned int mode;			/* subsystem mode */
-	unsigned int debug;			/* debug on|off */
+	unsigned int debug;			/* debug on|off|trace */
 	int syslog_priority;			/* priority */
 	int logfile_priority;			/* priority to file */
 	int init_status;			/* internal field to handle init queues
@@ -344,7 +344,7 @@ int _logsys_system_setup(
 		"%s", mainsystem);
 
 	logsys_loggers[i].mode = mode;
-	logsys_loggers[i].debug = 0;
+	logsys_loggers[i].debug = LOGSYS_DEBUG_OFF;
 	logsys_loggers[i].file_idx = 0;
 	logsys_loggers[i].logfile_priority = syslog_priority;
 	logsys_loggers[i].syslog_priority = syslog_priority;
@@ -709,9 +709,19 @@ static void _logsys_config_apply_per_file(int32_t s, const char *filename)
 			QB_LOG_FILTER_FILE, filename, LOG_TRACE);
 	}
 
-	if (logsys_loggers[s].debug) {
-		syslog_priority = LOG_DEBUG;
-		logfile_priority = LOG_DEBUG;
+	if (logsys_loggers[s].debug != LOGSYS_DEBUG_OFF) {
+		switch (logsys_loggers[s].debug) {
+		case LOGSYS_DEBUG_ON:
+			syslog_priority = LOG_DEBUG;
+			logfile_priority = LOG_DEBUG;
+			break;
+		case LOGSYS_DEBUG_TRACE:
+			syslog_priority = LOG_TRACE;
+			logfile_priority = LOG_TRACE;
+			break;
+		default:
+			assert(0);
+		}
 	}
 	qb_log_filter_ctl(QB_LOG_SYSLOG, QB_LOG_FILTER_ADD,
 		QB_LOG_FILTER_FILE, filename,
diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h
index fcce049..f636e7c 100644
--- a/include/corosync/logsys.h
+++ b/include/corosync/logsys.h
@@ -72,6 +72,7 @@ extern "C" {
 #define LOGSYS_LEVEL_NOTICE		LOG_NOTICE
 #define LOGSYS_LEVEL_INFO		LOG_INFO
 #define LOGSYS_LEVEL_DEBUG		LOG_DEBUG
+#define LOGSYS_LEVEL_TRACE		LOG_TRACE
 
 /*
  * logsys_logger bits
@@ -83,6 +84,13 @@ extern "C" {
 #define LOGSYS_MAX_SUBSYS_NAMELEN	64
 #define LOGSYS_MAX_PERROR_MSG_LEN	128
 
+/*
+ * Debug levels
+ */
+#define LOGSYS_DEBUG_OFF		0
+#define LOGSYS_DEBUG_ON			1
+#define LOGSYS_DEBUG_TRACE		2
+
 #ifndef LOGSYS_UTILS_ONLY
 
 /*
diff --git a/man/corosync.conf.5 b/man/corosync.conf.5
index 48acfcd..31cb9f7 100644
--- a/man/corosync.conf.5
+++ b/man/corosync.conf.5
@@ -578,7 +578,8 @@ The default is: info.
 
 .TP
 debug
-This specifies whether debug output is logged for this particular logger.
+This specifies whether debug output is logged for this particular logger. Also can contain
+value trace, what is highest level of debug informations.
 
 The default is off.
 
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux