aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-11 17:26:02 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-11 17:26:02 +0100
commit8c5dafb02fdb2eb6009d55aa6bf22c8d0c4feb00 (patch)
tree5221d9f13293016e3a4c0e17a572c614e49441eb /src/libserver
parent673986f9618514c66f05d13c6f663abc942e44c4 (diff)
downloadrspamd-8c5dafb02fdb2eb6009d55aa6bf22c8d0c4feb00.tar.gz
rspamd-8c5dafb02fdb2eb6009d55aa6bf22c8d0c4feb00.zip
[Minor] Add logging variable for forced actions
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_utils.c3
-rw-r--r--src/libserver/task.c30
3 files changed, 33 insertions, 1 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index c583766c4..cb3581e97 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -236,6 +236,7 @@ enum rspamd_log_format_type {
RSPAMD_LOG_LUA,
RSPAMD_LOG_DIGEST,
RSPAMD_LOG_FILENAME,
+ RSPAMD_LOG_FORCED_ACTION,
};
enum rspamd_log_format_flags {
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 3d5b69050..ff1e77d15 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -446,6 +446,9 @@ rspamd_config_process_var (struct rspamd_config *cfg, const rspamd_ftok_t *var,
else if (rspamd_ftok_cstr_equal (&tok, "filename", TRUE)) {
type = RSPAMD_LOG_FILENAME;
}
+ else if (rspamd_ftok_cstr_equal (&tok, "forced_action", TRUE)) {
+ type = RSPAMD_LOG_FORCED_ACTION;
+ }
else {
msg_err_config ("unknown log variable: %T", &tok);
return FALSE;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 42d9b1789..f4a09fd30 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -1010,6 +1010,11 @@ rspamd_task_log_check_condition (struct rspamd_task *task,
ret = TRUE;
}
break;
+ case RSPAMD_LOG_FORCED_ACTION:
+ if (task->result->passthrough_result) {
+ ret = TRUE;
+ }
+ break;
default:
ret = TRUE;
break;
@@ -1292,7 +1297,7 @@ rspamd_task_log_variable (struct rspamd_task *task,
{
rspamd_fstring_t *res = logbuf;
rspamd_ftok_t var = {.begin = NULL, .len = 0};
- static gchar numbuf[64];
+ static gchar numbuf[128];
static const gchar undef[] = "undef";
switch (lf->type) {
@@ -1412,6 +1417,29 @@ rspamd_task_log_variable (struct rspamd_task *task,
var.len = sizeof (undef) - 1;
}
break;
+ case RSPAMD_LOG_FORCED_ACTION:
+ if (task->result->passthrough_result) {
+ struct rspamd_passthrough_result *pr = task->result->passthrough_result;
+
+ if (!isnan (pr->target_score)) {
+ var.len = rspamd_snprintf (numbuf, sizeof (numbuf),
+ "%s \"%s\"; score=%.2f (set by %s)",
+ rspamd_action_to_str (pr->action),
+ pr->message, pr->target_score, pr->module);
+ }
+ else {
+ var.len = rspamd_snprintf (numbuf, sizeof (numbuf),
+ "%s \"%s\"; score=nan (set by %s)",
+ rspamd_action_to_str (pr->action),
+ pr->message, pr->module);
+ }
+ var.begin = numbuf;
+ }
+ else {
+ var.begin = undef;
+ var.len = sizeof (undef) - 1;
+ }
+ break;
default:
var = rspamd_task_log_metric_res (task, lf);
break;