Hi Steven,
the following patch removes a very confusing setting for logsys and fixes
the debug=on behavior as described in openais.conf.5.
The first problem is that we are mixing settings for LOG_LEVEL in both
LOGSYS_DECLARE_SYSTEM and LOGSYS_DECLARE_(NO)SUBSYS.
So completely remove the LOG_LEVEL setting from LOGSYS_DECLARE_SYSTEM by
killing LOG_MODE_DISPLAY_DEBUG that was not even used correctly across the
code.
At the same time i spotted that the main debug=on option was not behaving
as described in the man page.
Fix the behavior by overriding subsys setting only when those are not
available.
The patch is on top of svn trunk 1552. If applied _after_ the previous
patch, it will have a 25 lines offset in exec/mainconfig.c but no
rejections. The resulting code will still be functional as expected.
Please apply
Fabio
--
I'm going to make him an offer he can't refuse.
Index: test/logsys_t1.c
===================================================================
--- test/logsys_t1.c (revision 1552)
+++ test/logsys_t1.c (working copy)
@@ -36,7 +36,7 @@
#include "../exec/logsys.h"
LOGSYS_DECLARE_SYSTEM ("logsystestNOsubsystems",
- LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED |
LOG_MODE_DISPLAY_DEBUG,
+ LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED,
NULL,
LOG_DAEMON);
Index: test/logsys_t2.c
===================================================================
--- test/logsys_t2.c (revision 1552)
+++ test/logsys_t2.c (working copy)
@@ -36,7 +36,7 @@
#include "../exec/logsys.h"
LOGSYS_DECLARE_SYSTEM ("logtest_t2",
- LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED |
LOG_MODE_DISPLAY_DEBUG | LOG_MODE_BUFFER_BEFORE_CONFIG,
+ LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED |
LOG_MODE_BUFFER_BEFORE_CONFIG,
NULL,
LOG_DAEMON);
@@ -48,7 +48,7 @@
/*
* fork could occur here and the file to output to could be set
*/
- logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR |
LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_DISPLAY_DEBUG |
LOG_MODE_FLUSH_AFTER_CONFIG);
+ logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR |
LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_FLUSH_AFTER_CONFIG);
log_printf(LOG_NOTICE, "Hello, world!\n");
log_printf(LOG_DEBUG, "If you see this, the logger's busted\n");
@@ -68,7 +68,7 @@
log_printf(LOG_DEBUG, "Debug 1\n");
- logsys_config_mode_set (LOG_MODE_DISPLAY_DEBUG |
LOG_MODE_OUTPUT_STDERR);
+ logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR);
log_printf(LOG_DEBUG, "Debug 2\n");
Index: exec/logsys.h
===================================================================
--- exec/logsys.h (revision 1552)
+++ exec/logsys.h (working copy)
@@ -50,9 +50,8 @@
#define LOG_MODE_DISPLAY_PRIORITY (1<<5)
#define LOG_MODE_DISPLAY_FILELINE (1<<6)
#define LOG_MODE_DISPLAY_TIMESTAMP (1<<7)
-#define LOG_MODE_DISPLAY_DEBUG (1<<8)
-#define LOG_MODE_BUFFER_BEFORE_CONFIG (1<<9)
-#define LOG_MODE_FLUSH_AFTER_CONFIG (1<<10)
+#define LOG_MODE_BUFFER_BEFORE_CONFIG (1<<8)
+#define LOG_MODE_FLUSH_AFTER_CONFIG (1<<9)
/*
* Log priorities, compliant with syslog and SA Forum Log spec.
Index: exec/mainconfig.c
===================================================================
--- exec/mainconfig.c (revision 1552)
+++ exec/mainconfig.c (working copy)
@@ -106,6 +106,7 @@
unsigned int object_logger_subsys_handle;
char *value;
char *error_reason = error_string_response;
+ int global_debug = 0;
memset (main_config, 0, sizeof (struct main_config));
@@ -145,10 +146,10 @@
if (!objdb_get_string (objdb,object_service_handle, "debug",
&value)) {
if (strcmp (value, "on") == 0) {
- main_config->logmode |= LOG_MODE_DISPLAY_DEBUG;
+ global_debug = 1;
} else
if (strcmp (value, "off") == 0) {
- main_config->logmode &= ~LOG_MODE_DISPLAY_DEBUG;
+ global_debug = 0;
} else {
goto parse_error;
}
@@ -237,6 +238,11 @@
goto parse_error;
}
}
+ else {
+ if (global_debug)
+ logsys_logger.priority =
LOG_LEVEL_DEBUG;
+ }
+
if (!objdb_get_string (objdb,
object_logger_subsys_handle, "tags", &value)) {
char *token = strtok (value, "|");
Index: exec/main.c
===================================================================
--- exec/main.c (revision 1552)
+++ exec/main.c (working copy)
@@ -83,7 +83,7 @@
#include "version.h"
LOGSYS_DECLARE_SYSTEM ("openais",
- LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED |
LOG_MODE_DISPLAY_DEBUG | LOG_MODE_BUFFER_BEFORE_CONFIG,
+ LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED |
LOG_MODE_BUFFER_BEFORE_CONFIG,
NULL,
LOG_DAEMON);
Index: man/logsys_overview.8
===================================================================
--- man/logsys_overview.8 (revision 1552)
+++ man/logsys_overview.8 (working copy)
@@ -70,7 +70,6 @@
LOG_MODE_DISPLAY_PRIORITY: Output the priority of the log entry in the message
contents. This mode is currently not implemented.
LOG_MODE_DISPLAY_FILELINE: Output the file and line at which the log message
was created.
LOG_MODE_DISPLAY_TIMESTAMP: Output the timestamp of the message.
-LOG_MODE_DISPLAY_DEBUG: Display debug level messages
LOG_MODE_BUFFER_BEFORE_CONFIG: This mode is used to buffer log messages before
logsys_mode_config is called. This is useful in applications in which the
logging file isn't known before the application is compiled and must be set
dynamically. It is also useful when an application calls fork to disconnect
the local tty and should hold logging of messages until after the fork.
LOG_MODE_FLUSH_AFTER_CONFIG: This mode is used to flush any buffered messages
when the LOG_MODE_BUFFER_BEFORE_CONFIG declartion is specified in the
declartion of the logger.
The file parameter specifies the filename that should be used to log messages.
This parameter may be NULL if LOG_MODE_OUTPUT_FILE is not specified.
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais