summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/param/param_table.c12
-rw-r--r--lib/util/debug.c39
-rw-r--r--lib/util/debug.h8
3 files changed, 50 insertions, 9 deletions
diff --git a/lib/param/param_table.c b/lib/param/param_table.c
index cd6e3403a4c..512de250a2f 100644
--- a/lib/param/param_table.c
+++ b/lib/param/param_table.c
@@ -418,6 +418,18 @@ static const struct enum_list enum_spotlight_backend[] = {
{-1, NULL}
};
+static const struct enum_list enum_debug_syslog_format[] = {
+ {DEBUG_SYSLOG_FORMAT_NO, "No"},
+ {DEBUG_SYSLOG_FORMAT_NO, "False"},
+ {DEBUG_SYSLOG_FORMAT_NO, "0"},
+ {DEBUG_SYSLOG_FORMAT_IN_LOGS, "in_logs"},
+ {DEBUG_SYSLOG_FORMAT_IN_LOGS, "Yes"},
+ {DEBUG_SYSLOG_FORMAT_IN_LOGS, "True"},
+ {DEBUG_SYSLOG_FORMAT_IN_LOGS, "1"},
+ {DEBUG_SYSLOG_FORMAT_ALWAYS, "always"},
+ {-1, NULL}
+};
+
/* Note: We do not initialise the defaults union - it is not allowed in ANSI C
*
* NOTE: Handling of duplicated (synonym) parameters:
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 43d5151fbab..95de5ce3595 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -1557,10 +1557,25 @@ void check_log_size( void )
static void Debug1(const char *msg, size_t msg_len)
{
int old_errno = errno;
+ enum debug_logtype logtype = state.logtype;
debug_count++;
- switch(state.logtype) {
+ if (state.settings.debug_syslog_format == DEBUG_SYSLOG_FORMAT_ALWAYS) {
+ switch(state.logtype) {
+ case DEBUG_STDOUT:
+ case DEBUG_STDERR:
+ case DEBUG_DEFAULT_STDOUT:
+ case DEBUG_DEFAULT_STDERR:
+ /* Behave the same as logging to a file */
+ logtype = DEBUG_FILE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ switch(logtype) {
case DEBUG_CALLBACK:
debug_callback_log(msg, msg_len, current_msg_level);
break;
@@ -1749,23 +1764,31 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
dbgsetclass(level, cls);
- /* Don't print a header if we're logging to stdout. */
- if ( state.logtype != DEBUG_FILE ) {
- return( true );
+ /*
+ * Don't print a header if we're logging to stdout,
+ * unless 'debug syslog format = always'
+ */
+ if (state.logtype != DEBUG_FILE &&
+ state.settings.debug_syslog_format != DEBUG_SYSLOG_FORMAT_ALWAYS)
+ {
+ return true;
}
- /* Print the header if timestamps are turned on. If parameters are
- * not yet loaded, then default to timestamps on.
+ /*
+ * Print the header if timestamps (or debug syslog format) is
+ * turned on. If parameters are not yet loaded, then default
+ * to timestamps on.
*/
if (!(state.settings.timestamp_logs ||
state.settings.debug_prefix_timestamp ||
- state.settings.debug_syslog_format)) {
+ state.settings.debug_syslog_format != DEBUG_SYSLOG_FORMAT_NO))
+ {
return true;
}
GetTimeOfDay(&tv);
- if (state.settings.debug_syslog_format) {
+ if (state.settings.debug_syslog_format != DEBUG_SYSLOG_FORMAT_NO) {
if (state.settings.debug_hires_timestamp) {
timeval_str_buf(&tv, true, true, &tvbuf);
} else {
diff --git a/lib/util/debug.h b/lib/util/debug.h
index 4bbfa05df65..4e5ce3da035 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -325,12 +325,18 @@ enum debug_logtype {
DEBUG_CALLBACK = 5
};
+enum debug_syslog_format {
+ DEBUG_SYSLOG_FORMAT_NO = 0,
+ DEBUG_SYSLOG_FORMAT_IN_LOGS = 1,
+ DEBUG_SYSLOG_FORMAT_ALWAYS = 2,
+};
+
struct debug_settings {
size_t max_log_size;
bool timestamp_logs;
bool debug_prefix_timestamp;
bool debug_hires_timestamp;
- bool debug_syslog_format;
+ enum debug_syslog_format debug_syslog_format;
bool debug_pid;
bool debug_uid;
bool debug_class;