diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-11 16:11:13 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-11 16:11:13 +0100 |
commit | 8cc53b5035580ec35a627aff762200f0f3788ba2 (patch) | |
tree | 294cf2a3b848f0e0035a9943e037397969789fe2 /src/libserver/task.c | |
parent | 4932b636ef23b7b0c9c356c9144457039253945e (diff) | |
download | rspamd-8cc53b5035580ec35a627aff762200f0f3788ba2.tar.gz rspamd-8cc53b5035580ec35a627aff762200f0f3788ba2.zip |
[Feature] Limit logging of elements that could have too many items
Diffstat (limited to 'src/libserver/task.c')
-rw-r--r-- | src/libserver/task.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libserver/task.c b/src/libserver/task.c index 3d6387b52..ce95b927d 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -26,6 +26,11 @@ #include "utlist.h" #include <math.h> +/* + * Do not print more than this amount of elts + */ +static const int max_log_elts = 7; + static GQuark rspamd_task_quark (void) { @@ -752,7 +757,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task, rspamd_fstring_t *symbuf; struct symbol *sym; GPtrArray *sorted_symbols; - guint i; + guint i, j; mres = g_hash_table_lookup (task->results, DEFAULT_METRIC); @@ -810,8 +815,16 @@ rspamd_task_log_metric_res (struct rspamd_task *task, rspamd_printf_fstring (&symbuf, "{"); + j = 0; + for (cur = sym->options; cur != NULL; cur = g_list_next (cur)) { rspamd_printf_fstring (&symbuf, "%s;", cur->data); + + if (j >= max_log_elts) { + rspamd_printf_fstring (&symbuf, "...;"); + break; + } + j ++; } rspamd_printf_fstring (&symbuf, "}"); @@ -892,6 +905,7 @@ rspamd_task_write_ialist (struct rspamd_task *task, lim = internet_address_list_length (ialist); } + varbuf = rspamd_fstring_new (); for (i = 0; i < lim; i++) { @@ -908,6 +922,11 @@ rspamd_task_write_ialist (struct rspamd_task *task, varbuf = rspamd_fstring_append (varbuf, ",", 1); } } + + if (i >= max_log_elts) { + varbuf = rspamd_fstring_append (varbuf, "...", 3); + break; + } } if (varbuf->len > 0) { @@ -951,6 +970,11 @@ rspamd_task_write_addr_list (struct rspamd_task *task, varbuf = rspamd_fstring_append (varbuf, ",", 1); } } + + if (i >= max_log_elts) { + varbuf = rspamd_fstring_append (varbuf, "...", 3); + break; + } } if (varbuf->len > 0) { |