Browse Source

TT#14008 add config knob for max log line length

This is useful because we log to stderr, which technically would allow
unlimited log line length, but this is in fact turned over to syslog,
which truncates log lines that are too long.

Change-Id: Iee8994842335ab1cf94941c14eced01e29120bc9
pull/1407/head
Richard Fuchs 4 years ago
parent
commit
56d4ff74f2
5 changed files with 16 additions and 6 deletions
  1. +7
    -0
      daemon/rtpengine.pod
  2. +7
    -3
      lib/auxlib.c
  3. +1
    -0
      lib/auxlib.h
  4. +1
    -1
      lib/loglib.c
  5. +0
    -2
      lib/loglib.h

+ 7
- 0
daemon/rtpengine.pod View File

@ -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<INT>
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.


+ 7
- 3
lib/auxlib.c View File

@ -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;


+ 1
- 0
lib/auxlib.h View File

@ -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;


+ 1
- 1
lib/loglib.c View File

@ -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');


+ 0
- 2
lib/loglib.h View File

@ -19,8 +19,6 @@
extern int ilog_facility;
extern unsigned int max_log_line_length;
extern int get_local_log_level(unsigned int);


Loading…
Cancel
Save