diff --git a/daemon/rtpengine.pod b/daemon/rtpengine.pod index 0b27b6fb9..d392f8ad7 100644 --- a/daemon/rtpengine.pod +++ b/daemon/rtpengine.pod @@ -301,6 +301,13 @@ Only useful in combination with B<--foreground>. Split multi-line log messages into individual log messages so that each line receives its own log line prefix. +=item B<--max-log-line-length=>I + +Split log lines into multiple lines when they exceed the character count given +here. Can be set to a negative value to allow unlimited length log lines. Set +to zero for the default value, which is unlimited if logging to stderr, or 500 +if logging to syslog. + =item B<--no-log-timestamps> Don't add timestamps to log lines written to stderr. diff --git a/lib/auxlib.c b/lib/auxlib.c index cf9318912..24902504d 100644 --- a/lib/auxlib.c +++ b/lib/auxlib.c @@ -153,6 +153,7 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char #include "loglevels.h" { "log-stderr", 'E', 0, G_OPTION_ARG_NONE, &rtpe_common_config_ptr->log_stderr, "Log on stderr instead of syslog", NULL }, { "split-logs", 0, 0, G_OPTION_ARG_NONE, &rtpe_common_config_ptr->split_logs, "Split multi-line log messages", NULL }, + { "max-log-line-length",0, 0, G_OPTION_ARG_INT, &rtpe_common_config_ptr->max_log_line_length, "Break log lines at this length","INT" }, { "no-log-timestamps", 0, 0, G_OPTION_ARG_NONE, &rtpe_common_config_ptr->no_log_timestamps,"Drop timestamps from log lines to stderr",NULL }, { "log-mark-prefix", 0, 0, G_OPTION_ARG_STRING, &rtpe_common_config_ptr->log_mark_prefix,"Prefix for sensitive log info", NULL }, { "log-mark-suffix", 0, 0, G_OPTION_ARG_STRING, &rtpe_common_config_ptr->log_mark_suffix,"Suffix for sensitive log info", NULL }, @@ -323,10 +324,13 @@ out: rtpe_common_config_ptr->log_levels[i] = rtpe_common_config_ptr->default_log_level; } - if (rtpe_common_config_ptr->log_stderr) { + if (rtpe_common_config_ptr->log_stderr) write_log = log_to_stderr; - max_log_line_length = 0; - } + else if (rtpe_common_config_ptr->max_log_line_length == 0) + rtpe_common_config_ptr->max_log_line_length = 500; + + if (rtpe_common_config_ptr->max_log_line_length < 0) + rtpe_common_config_ptr->max_log_line_length = 0; if (rtpe_common_config_ptr->thread_stack == 0) rtpe_common_config_ptr->thread_stack = 2048; diff --git a/lib/auxlib.h b/lib/auxlib.h index 6d1b72bec..af8e48394 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -28,6 +28,7 @@ struct rtpengine_common_config { char *pidfile; int foreground; int thread_stack; + int max_log_line_length; }; extern struct rtpengine_common_config *rtpe_common_config_ptr; diff --git a/lib/loglib.c b/lib/loglib.c index c83fc61e5..d251ff2dd 100644 --- a/lib/loglib.c +++ b/lib/loglib.c @@ -193,7 +193,7 @@ void __vpilog(int prio, const char *prefix, const char *fmt, va_list ap) { piece = msg; while (1) { - unsigned int max_line_len = max_log_line_length; + unsigned int max_line_len = rtpe_common_config_ptr->max_log_line_length; unsigned int skip_len = max_line_len; if (rtpe_common_config_ptr->split_logs) { char *newline = strchr(piece, '\n'); diff --git a/lib/loglib.h b/lib/loglib.h index 463e6732c..26db30198 100644 --- a/lib/loglib.h +++ b/lib/loglib.h @@ -19,8 +19,6 @@ extern int ilog_facility; -extern unsigned int max_log_line_length; - extern int get_local_log_level(unsigned int);