TT#45617 add no-log-timestamps option

Log lines written to stderr that are consumed by journald will already
have timestamps added to them. Drop the redundant unixtime output for
this use case.

Change-Id: I34886a69a0ef90de2eb84ee8f446cbad624302c1
changes/24/28224/2
Richard Fuchs 6 years ago
parent 4cdf1067cb
commit 354f75490d

@ -244,6 +244,11 @@ Write SRTP keys to error log instead of debug log.
Log to stderr instead of syslog.
Only useful in combination with B<--foreground>.
=item B<-E>, B<--no-log-timestamps>
Don't add timestamps to log lines written to stderr.
Only useful in combination with B<--log-stderr>.
=item B<--num-threads=>I<INT>
How many worker threads to create, must be at least one.

@ -9,7 +9,7 @@ Type=notify
EnvironmentFile=/etc/default/ngcp-rtpengine-daemon
PIDFile=/run/ngcp-rtpengine-daemon.pid
ExecStartPre=/usr/sbin/ngcp-rtpengine-iptables-setup start
ExecStart=/usr/sbin/rtpengine -f -E --pidfile /run/ngcp-rtpengine-daemon.pid --config-file /etc/rtpengine/rtpengine.conf --table $TABLE
ExecStart=/usr/sbin/rtpengine -f -E --no-log-timestamps --pidfile /run/ngcp-rtpengine-daemon.pid --config-file /etc/rtpengine/rtpengine.conf --table $TABLE
ExecStopPost=/usr/sbin/ngcp-rtpengine-iptables-setup stop
[Install]

@ -9,7 +9,7 @@ Requires=ngcp-rtpengine-recording-nfs-mount.service
[Service]
Type=notify
PIDFile=/run/ngcp-rtpengine-recording-daemon.pid
ExecStart=/usr/sbin/rtpengine-recording -f -E --pidfile /run/ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf
ExecStart=/usr/sbin/rtpengine-recording -f -E --no-log-timestamps --pidfile /run/ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf
[Install]
WantedBy=multi-user.target

@ -113,6 +113,7 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char
{ "log-facility", 0, 0, G_OPTION_ARG_STRING, &rtpe_common_config_ptr->log_facility, "Syslog facility to use for logging", "daemon|local0|...|local7"},
{ "log-level", 'L', 0, G_OPTION_ARG_INT, (void *)&rtpe_common_config_ptr->log_level,"Mask log priorities above this level","INT" },
{ "log-stderr", 'E', 0, G_OPTION_ARG_NONE, &rtpe_common_config_ptr->log_stderr, "Log on stderr instead of syslog", NULL },
{ "no-log-timestamps", 0, 0, G_OPTION_ARG_NONE, &rtpe_common_config_ptr->no_log_timestamps,"Drop timestamps from log lines to stderr",NULL },
{ "pidfile", 'p', 0, G_OPTION_ARG_FILENAME, &rtpe_common_config_ptr->pidfile, "Write PID to file", "FILE" },
{ "foreground", 'f', 0, G_OPTION_ARG_NONE, &rtpe_common_config_ptr->foreground, "Don't fork to background", NULL },
{ NULL, }

@ -18,6 +18,7 @@ struct rtpengine_common_config {
char *log_facility;
volatile int log_level;
int log_stderr;
int no_log_timestamps;
char *pidfile;
int foreground;
};

@ -90,10 +90,14 @@ static void vlog_to_stderr(int facility_priority, const char *format, va_list ap
return;
}
gettimeofday(&tv_now, NULL);
if (rtpe_common_config_ptr->no_log_timestamps)
fprintf(stderr, "%s\n", msg);
else {
gettimeofday(&tv_now, NULL);
fprintf(stderr, "[%lu.%06lu] %s\n", (unsigned long) tv_now.tv_sec,
(unsigned long) tv_now.tv_usec, msg);
fprintf(stderr, "[%lu.%06lu] %s\n", (unsigned long) tv_now.tv_sec,
(unsigned long) tv_now.tv_usec, msg);
}
free(msg);
}

Loading…
Cancel
Save