commit 6cdd90b: [Fix] Honour `systemd` setting when logging to console (#3514)
Andrew Lewis
nerf at judo.za.org
Wed Oct 14 09:14:06 UTC 2020
Author: Andrew Lewis
Date: 2020-10-14 10:03:20 +0200
URL: https://github.com/rspamd/rspamd/commit/6cdd90b7cabb77b970f646cdeef54a3ffa9f07d2 (refs/pull/3515/head)
[Fix] Honour `systemd` setting when logging to console (#3514)
---
src/libserver/logger/logger_console.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/libserver/logger/logger_console.c b/src/libserver/logger/logger_console.c
index b348aa929..9aad85f6e 100644
--- a/src/libserver/logger/logger_console.c
+++ b/src/libserver/logger/logger_console.c
@@ -179,8 +179,11 @@ rspamd_log_console_log (const gchar *module, const gchar *id,
rspamd_file_lock (fd, FALSE);
#endif
- log_time (rspamd_get_calendar_ticks (),
- rspamd_log, timebuf, sizeof (timebuf));
+ if (!(rspamd_log->flags & RSPAMD_LOG_FLAG_SYSTEMD)) {
+ log_time (rspamd_get_calendar_ticks (),
+ rspamd_log, timebuf, sizeof (timebuf));
+ }
+
if (priv->log_color) {
if (level_flags & (G_LOG_LEVEL_INFO|G_LOG_LEVEL_MESSAGE)) {
/* White */
@@ -215,12 +218,20 @@ rspamd_log_console_log (const gchar *module, const gchar *id,
iov[niov++].iov_len = 1;
}
else {
- r += rspamd_snprintf (tmpbuf + r,
- sizeof (tmpbuf) - r,
- "%s #%P(%s) ",
- timebuf,
- rspamd_log->pid,
- rspamd_log->process_type);
+ if (!(rspamd_log->flags & RSPAMD_LOG_FLAG_SYSTEMD)) {
+ r += rspamd_snprintf (tmpbuf + r,
+ sizeof (tmpbuf) - r,
+ "%s #%P(%s) ",
+ timebuf,
+ rspamd_log->pid,
+ rspamd_log->process_type);
+ } else {
+ r += rspamd_snprintf (tmpbuf + r,
+ sizeof (tmpbuf) - r,
+ "#%P(%s) ",
+ rspamd_log->pid,
+ rspamd_log->process_type);
+ }
modulebuf[0] = '\0';
mremain = sizeof (modulebuf);
More information about the Commits
mailing list