From 326f96d599a7b7906c6c857f895ef344212eab21 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 8 Mar 2014 22:12:17 +0000 Subject: Add Log header to prevent logging of a task. --- src/protocol.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/protocol.c') diff --git a/src/protocol.c b/src/protocol.c index 1a831aa25..846648212 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -94,6 +94,7 @@ #define JSON_HEADER "Json" #define HOSTNAME_HEADER "Hostname" #define DELIVER_TO_HEADER "Deliver-To" +#define NO_LOG_HEADER "Log" static GList *custom_commands = NULL; @@ -382,6 +383,17 @@ rspamd_protocol_handle_headers (struct worker_task *task, struct rspamd_http_mes res = FALSE; } break; + case 'l': + case 'L': + if (g_ascii_strcasecmp (headern, NO_LOG_HEADER) == 0) { + if (g_ascii_strcasecmp (h->value->str, "no") == 0) { + task->no_log = TRUE; + } + } + else { + res = FALSE; + } + break; default: debug_task ("wrong header: %s", headern); res = FALSE; @@ -667,7 +679,9 @@ write_check_reply (struct rspamd_http_message *msg, struct worker_task *task) rspamd_printf_gstring (logbuf, "user: %s, ", task->user); } - rspamd_roll_history_update (task->worker->srv->history, task); + if (!task->no_log) { + rspamd_roll_history_update (task->worker->srv->history, task); + } g_hash_table_iter_init (&hiter, task->results); /* Convert results to an ucl object */ @@ -690,7 +704,9 @@ write_check_reply (struct rspamd_http_message *msg, struct worker_task *task) top = ucl_object_insert_key (top, ucl_object_fromstring (task->message_id), "message-id", 0, false); write_hashes_to_log (task, logbuf); - msg_info ("%v", logbuf); + if (!task->no_log) { + msg_info ("%v", logbuf); + } g_string_free (logbuf, TRUE); msg->body = g_string_sized_new (BUFSIZ); -- cgit v1.2.3