diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-17 14:27:06 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-17 14:27:06 +0100 |
commit | 80959ef9ac9ed96616c61c8793498c4709615401 (patch) | |
tree | 7e32989eb3eade0361c25887720dbf4b5d04e83a /src | |
parent | 7ee08bcddf11b2c41c7517afd344c2ae62247d3f (diff) | |
download | rspamd-80959ef9ac9ed96616c61c8793498c4709615401.tar.gz rspamd-80959ef9ac9ed96616c61c8793498c4709615401.zip |
Add special knob for systemd logging.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_file.h | 1 | ||||
-rw-r--r-- | src/libserver/cfg_rcl.c | 10 | ||||
-rw-r--r-- | src/libutil/logger.c | 27 |
3 files changed, 30 insertions, 8 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 4d87bf8e4..6ce3f58f7 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -202,6 +202,7 @@ struct rspamd_config { GHashTable *debug_modules; /**< logging modules to debug */ gboolean log_color; /**< output colors for console output */ gboolean log_extended; /**< log extended information */ + gboolean log_systemd; /**< special case for systemd logger */ gboolean mlock_statfile_pool; /**< use mlock (2) for locking statfiles */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 3a98cdd55..263ba9e40 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -1191,6 +1191,16 @@ rspamd_rcl_config_init (void) G_STRUCT_OFFSET (struct rspamd_config, log_color), 0); rspamd_rcl_add_default_handler (sub, + "log_systemd", + rspamd_rcl_parse_struct_boolean, + G_STRUCT_OFFSET (struct rspamd_config, log_systemd), + 0); + rspamd_rcl_add_default_handler (sub, + "systemd", + rspamd_rcl_parse_struct_boolean, + G_STRUCT_OFFSET (struct rspamd_config, log_systemd), + 0); + rspamd_rcl_add_default_handler (sub, "debug_modules", rspamd_rcl_parse_struct_string_list, G_STRUCT_OFFSET (struct rspamd_config, debug_modules), diff --git a/src/libutil/logger.c b/src/libutil/logger.c index 7a10b4ec7..cca21f870 100644 --- a/src/libutil/logger.c +++ b/src/libutil/logger.c @@ -748,9 +748,12 @@ file_log_function (const gchar *log_domain, } /* Format time */ - tms = localtime (&now); + if (!rspamd_log->cfg->log_systemd) { + tms = localtime (&now); + + strftime (timebuf, sizeof (timebuf), "%F %H:%M:%S", tms); + } - strftime (timebuf, sizeof (timebuf), "%F %H:%M:%S", tms); cptype = g_quark_to_string (rspamd_log->process_type); if (rspamd_log->cfg->log_color) { @@ -771,12 +774,20 @@ file_log_function (const gchar *log_domain, r = 0; } - r += rspamd_snprintf (tmpbuf + r, - sizeof (tmpbuf) - r, - "%s #%P(%s) ", - timebuf, - rspamd_log->pid, - cptype); + if (!rspamd_log->cfg->log_systemd) { + r += rspamd_snprintf (tmpbuf + r, + sizeof (tmpbuf) - r, + "%s #%P(%s) ", + timebuf, + rspamd_log->pid, + cptype); + } + else { + r += rspamd_snprintf (tmpbuf + r, + sizeof (tmpbuf) - r, + "(%s) ", + cptype); + } modulebuf[0] = '\0'; mremain = sizeof (modulebuf); |