]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow symbols params to be printed in logs
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Mar 2016 09:38:33 +0000 (09:38 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Mar 2016 09:38:56 +0000 (09:38 +0000)
src/libserver/cfg_file.h
src/libserver/cfg_utils.c
src/libserver/task.c

index a4e7d966c0ca7bc266f1ba4a1e69859d505118d0..6502f37b2274c367041bbc7da1f5173674d42f14 100644 (file)
@@ -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 {
index c710cb40e4ad4e84f89b36063751189663f50fbf..5e49d3a3d57f90c9a05d531181fc7949f2e56a11 100644 (file)
@@ -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;
        }
index b26cc9d3cae09ef199da24b24679b73f63bdda7d..cf26655f14c9f2eb85b7d7e6f6842c0e8ad4425b 100644 (file)
@@ -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,