diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-13 14:58:11 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-13 14:58:11 +0100 |
commit | 137ceb2eb102229ebbbd06bef2681d689d035647 (patch) | |
tree | bf1ad1d05e98bdff87589a7eb56945564bd9f419 /src/libserver/logger/logger_console.c | |
parent | 967e5ee83cb1e7bb17dde33686a48d27617b1e0c (diff) | |
download | rspamd-137ceb2eb102229ebbbd06bef2681d689d035647.tar.gz rspamd-137ceb2eb102229ebbbd06bef2681d689d035647.zip |
[Feature] Allow to log severity level explicitly
Diffstat (limited to 'src/libserver/logger/logger_console.c')
-rw-r--r-- | src/libserver/logger/logger_console.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/libserver/logger/logger_console.c b/src/libserver/logger/logger_console.c index c7857bdfe..3e142fe27 100644 --- a/src/libserver/logger/logger_console.c +++ b/src/libserver/logger/logger_console.c @@ -28,6 +28,7 @@ static const gchar lf_chr = '\n'; struct rspamd_console_logger_priv { gint fd; gint crit_fd; + gboolean log_severity; gboolean log_color; gboolean log_rspamadm; gboolean log_tty; @@ -63,6 +64,7 @@ rspamd_log_console_init (rspamd_logger_t *logger, struct rspamd_config *cfg, priv = g_malloc0 (sizeof (*priv)); priv->log_color = (logger->flags & RSPAMD_LOG_FLAG_COLOR); + priv->log_severity = (logger->flags & RSPAMD_LOG_FLAG_SEVERITY); priv->log_rspamadm = (logger->flags & RSPAMD_LOG_FLAG_RSPAMADM); if (priv->log_rspamadm) { @@ -224,12 +226,23 @@ rspamd_log_console_log (const gchar *module, const gchar *id, } else { 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); + if (priv->log_severity) { + r += rspamd_snprintf(tmpbuf + r, + sizeof(tmpbuf) - r, + "%s [%s] #%P(%s) ", + timebuf, + rspamd_get_log_severity_string (level_flags), + rspamd_log->pid, + rspamd_log->process_type); + } + else { + 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, |