Because logsys uses 3-bits for log level encoded in rec, it's impossible to add trace log level in clean way. Instead of that, we are using recid of TRACE1 for trace messages. So if trace is allowed in configuration file, we change old condition to log only LOGSYS_RECID_LOG to log also LOGSYS_RECID_TRACE1. Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> --- exec/logsys.c | 35 +++++++++++++++++++++++++++++------ exec/mainconfig.c | 10 ++++++++-- include/corosync/engine/logsys.h | 7 +++++++ man/corosync.conf.5 | 3 ++- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/exec/logsys.c b/exec/logsys.c index 4c3e11a..34de644 100644 --- a/exec/logsys.c +++ b/exec/logsys.c @@ -144,6 +144,7 @@ struct logsys_logger { int logfile_priority; /* priority to file */ int init_status; /* internal field to handle init queues for subsystems */ + unsigned int trace1_allowed; }; @@ -439,13 +440,14 @@ static void log_printf_to_logs ( int c; struct tm tm_res; - if (LOGSYS_DECODE_RECID(rec_ident) != LOGSYS_RECID_LOG) { - return; - } - subsysid = LOGSYS_DECODE_SUBSYSID(rec_ident); level = LOGSYS_DECODE_LEVEL(rec_ident); + if (!((LOGSYS_DECODE_RECID(rec_ident) == LOGSYS_RECID_LOG) || + (logsys_loggers[subsysid].trace1_allowed && LOGSYS_DECODE_RECID(rec_ident) == LOGSYS_RECID_TRACE1))) { + return; + } + while ((c = format_buffer[format_buffer_idx])) { cutoff = 0; if (c != '%') { @@ -960,6 +962,7 @@ int _logsys_system_setup( logsys_loggers[i].mode = mode; logsys_loggers[i].debug = debug; + logsys_loggers[i].trace1_allowed = 0; if (logsys_config_file_set_unlocked (i, &errstr, logfile) < 0) { pthread_mutex_unlock (&logsys_config_mutex); @@ -1495,12 +1498,32 @@ int logsys_config_debug_set ( if (subsys != NULL) { i = _logsys_config_subsys_get_unlocked (subsys); if (i >= 0) { - logsys_loggers[i].debug = debug; + switch (debug) { + case LOGSYS_DEBUG_OFF: + case LOGSYS_DEBUG_ON: + logsys_loggers[i].debug = debug; + logsys_loggers[i].trace1_allowed = 0; + break; + case LOGSYS_DEBUG_TRACE: + logsys_loggers[i].debug = LOGSYS_DEBUG_ON; + logsys_loggers[i].trace1_allowed = 1; + break; + } i = 0; } } else { for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) { - logsys_loggers[i].debug = debug; + switch (debug) { + case LOGSYS_DEBUG_OFF: + case LOGSYS_DEBUG_ON: + logsys_loggers[i].debug = debug; + logsys_loggers[i].trace1_allowed = 0; + break; + case LOGSYS_DEBUG_TRACE: + logsys_loggers[i].debug = LOGSYS_DEBUG_ON; + logsys_loggers[i].trace1_allowed = 1; + break; + } } i = 0; } diff --git a/exec/mainconfig.c b/exec/mainconfig.c index cbc41f5..d15dd49 100644 --- a/exec/mainconfig.c +++ b/exec/mainconfig.c @@ -424,14 +424,20 @@ static int corosync_main_config_set ( } if (!objdb_get_string (objdb, object_handle, "debug", &value)) { + if (strcmp (value, "trace") == 0) { + if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_TRACE) < 0) { + error_reason = "unable to set debug on"; + 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/include/corosync/engine/logsys.h b/include/corosync/engine/logsys.h index df1db1d..6b26a9f 100644 --- a/include/corosync/engine/logsys.h +++ b/include/corosync/engine/logsys.h @@ -58,6 +58,7 @@ extern "C" { #define LOGSYS_MODE_FORK (1<<3) #define LOGSYS_MODE_THREADED (1<<4) + /* * Log priorities, compliant with syslog and SA Forum Log spec. */ @@ -92,6 +93,12 @@ extern "C" { #define LOGSYS_RECID_TRACE7 (LOGSYS_RECID_MAX - 10) #define LOGSYS_RECID_TRACE8 (LOGSYS_RECID_MAX - 11) +/* + * Debug levels + */ +#define LOGSYS_DEBUG_OFF 0 +#define LOGSYS_DEBUG_ON 1 +#define LOGSYS_DEBUG_TRACE 2 /* * Internal APIs that must be globally exported diff --git a/man/corosync.conf.5 b/man/corosync.conf.5 index 82ec80e..bad9700 100644 --- a/man/corosync.conf.5 +++ b/man/corosync.conf.5 @@ -601,7 +601,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