aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-22 09:38:33 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-22 09:38:56 +0000
commit90bf870bd8d112e8317c9b2a38782a7a6666bbac (patch)
treeb87a0a63e0fab806c69f12f378f75387bcee1302
parentf684ccb51b81fbd7101f4c40a7bc9eb7a52363d5 (diff)
downloadrspamd-90bf870bd8d112e8317c9b2a38782a7a6666bbac.tar.gz
rspamd-90bf870bd8d112e8317c9b2a38782a7a6666bbac.zip
[Feature] Allow symbols params to be printed in logs
-rw-r--r--src/libserver/cfg_file.h3
-rw-r--r--src/libserver/cfg_utils.c8
-rw-r--r--src/libserver/task.c33
3 files changed, 29 insertions, 15 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index a4e7d966c..6502f37b2 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -210,7 +210,8 @@ enum rspamd_log_format_flags {
RSPAMD_LOG_FLAG_OPTIONAL = (1 << 0),
RSPAMD_LOG_FLAG_MIME_ALTERNATIVE = (1 << 1),
RSPAMD_LOG_FLAG_CONDITION = (1 << 2),
- RSPAMD_LOG_FLAG_SYMBOLS_SCORES = (1 << 3)
+ RSPAMD_LOG_FLAG_SYMBOLS_SCORES = (1 << 3),
+ RSPAMD_LOG_FLAG_SYMBOLS_PARAMS = (1 << 4)
};
struct rspamd_log_format {
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index c710cb40e..5e49d3a3d 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -346,6 +346,14 @@ rspamd_config_process_var (struct rspamd_config *cfg, const rspamd_ftok_t *var,
type = RSPAMD_LOG_SYMBOLS;
flags |= RSPAMD_LOG_FLAG_SYMBOLS_SCORES;
}
+ else if (rspamd_ftok_cstr_equal (&tok, "symbols_params", TRUE)) {
+ type = RSPAMD_LOG_SYMBOLS;
+ flags |= RSPAMD_LOG_FLAG_SYMBOLS_PARAMS;
+ }
+ else if (rspamd_ftok_cstr_equal (&tok, "symbols_scores_params", TRUE)) {
+ type = RSPAMD_LOG_SYMBOLS;
+ flags |= RSPAMD_LOG_FLAG_SYMBOLS_PARAMS|RSPAMD_LOG_FLAG_SYMBOLS_SCORES;
+ }
else if (rspamd_ftok_cstr_equal (&tok, "ip", TRUE)) {
type = RSPAMD_LOG_IP;
}
diff --git a/src/libserver/task.c b/src/libserver/task.c
index b26cc9d3c..cf26655f1 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -832,24 +832,29 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
sym = (struct symbol *) v;
if (first) {
- if (lf->flags & RSPAMD_LOG_FLAG_SYMBOLS_SCORES) {
- rspamd_printf_fstring (&symbuf, "%s(%.2f)", sym->name,
- sym->score);
- }
- else {
- rspamd_printf_fstring (&symbuf, "%s", sym->name);
- }
- first = FALSE;
+ rspamd_printf_fstring (&symbuf, "%s", sym->name);
}
else {
- if (lf->flags & RSPAMD_LOG_FLAG_SYMBOLS_SCORES) {
- rspamd_printf_fstring (&symbuf, ",%s(%.2f)", sym->name,
- sym->score);
- }
- else {
- rspamd_printf_fstring (&symbuf, ",%s", sym->name);
+ rspamd_printf_fstring (&symbuf, ",%s", sym->name);
+ }
+
+ if (lf->flags & RSPAMD_LOG_FLAG_SYMBOLS_SCORES) {
+ rspamd_printf_fstring (&symbuf, "(%.2f)", sym->score);
+ }
+
+ if (lf->flags & RSPAMD_LOG_FLAG_SYMBOLS_PARAMS) {
+ GList *cur;
+
+ rspamd_printf_fstring (&symbuf, "{");
+
+ for (cur = sym->options; cur != NULL; cur = g_list_next (cur)) {
+ rspamd_printf_fstring (&symbuf, "%s;", cur->data);
}
+
+ rspamd_printf_fstring (&symbuf, "}");
}
+
+ first = FALSE;
}
rspamd_mempool_add_destructor (task->task_pool,