diff --git a/daemon/rtpengine.pod b/daemon/rtpengine.pod index e9ee6bfa5..219af9bb0 100644 --- a/daemon/rtpengine.pod +++ b/daemon/rtpengine.pod @@ -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 How many worker threads to create, must be at least one. diff --git a/debian/ngcp-rtpengine-daemon.service b/debian/ngcp-rtpengine-daemon.service index 117eda514..2f4a0e8a2 100644 --- a/debian/ngcp-rtpengine-daemon.service +++ b/debian/ngcp-rtpengine-daemon.service @@ -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] diff --git a/debian/ngcp-rtpengine-recording-daemon.service b/debian/ngcp-rtpengine-recording-daemon.service index 3caa60acb..f7746df8a 100644 --- a/debian/ngcp-rtpengine-recording-daemon.service +++ b/debian/ngcp-rtpengine-recording-daemon.service @@ -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 diff --git a/lib/auxlib.c b/lib/auxlib.c index 52046cfe0..d72e2fb79 100644 --- a/lib/auxlib.c +++ b/lib/auxlib.c @@ -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, } diff --git a/lib/auxlib.h b/lib/auxlib.h index 637464ab8..b0d44988c 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -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; }; diff --git a/lib/loglib.c b/lib/loglib.c index 2837567e9..6f1e5d1e3 100644 --- a/lib/loglib.c +++ b/lib/loglib.c @@ -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); }