aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/logger/logger_file.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-05-13 14:58:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-05-13 14:58:11 +0100
commit137ceb2eb102229ebbbd06bef2681d689d035647 (patch)
treebf1ad1d05e98bdff87589a7eb56945564bd9f419 /src/libserver/logger/logger_file.c
parent967e5ee83cb1e7bb17dde33686a48d27617b1e0c (diff)
downloadrspamd-137ceb2eb102229ebbbd06bef2681d689d035647.tar.gz
rspamd-137ceb2eb102229ebbbd06bef2681d689d035647.zip
[Feature] Allow to log severity level explicitly
Diffstat (limited to 'src/libserver/logger/logger_file.c')
-rw-r--r--src/libserver/logger/logger_file.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/libserver/logger/logger_file.c b/src/libserver/logger/logger_file.c
index 3d5cc148b..81c44f8e7 100644
--- a/src/libserver/logger/logger_file.c
+++ b/src/libserver/logger/logger_file.c
@@ -36,6 +36,7 @@ struct rspamd_file_logger_priv {
gboolean throttling;
gchar *log_file;
gboolean is_buffered;
+ gboolean log_severity;
time_t throttling_time;
guint32 repeats;
guint64 last_line_cksum;
@@ -360,6 +361,7 @@ rspamd_log_file_init (rspamd_logger_t *logger, struct rspamd_config *cfg,
priv->log_file = g_strdup (cfg->log_file);
}
+ priv->log_severity = (logger->flags & RSPAMD_LOG_FLAG_SEVERITY);
priv->fd = rspamd_try_open_log_fd (logger, priv, uid, gid, err);
if (priv->fd == -1) {
@@ -506,12 +508,23 @@ rspamd_log_file_log (const gchar *module, const gchar *id,
r = 0;
if (!(rspamd_log->flags & RSPAMD_LOG_FLAG_SYSTEMD)) {
- r += rspamd_snprintf (tmpbuf + r,
- sizeof (tmpbuf) - r,
- "%s #%P(%s) ",
- timebuf,
- rspamd_log->pid,
- cptype);
+ 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,
+ cptype);
+ }
+ else {
+ r += rspamd_snprintf(tmpbuf + r,
+ sizeof(tmpbuf) - r,
+ "%s #%P(%s) ",
+ timebuf,
+ rspamd_log->pid,
+ cptype);
+ }
}
else {
r += rspamd_snprintf (tmpbuf + r,