From: Alexander Moisseev Date: Tue, 27 Aug 2019 09:11:14 +0000 (+0300) Subject: [Minor] autolearn: log some info on the message X-Git-Tag: 2.0~338^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F3018%2Fhead;p=rspamd.git [Minor] autolearn: log some info on the message --- diff --git a/lualib/lua_bayes_learn.lua b/lualib/lua_bayes_learn.lua index 5a46265e7..066e86a4d 100644 --- a/lualib/lua_bayes_learn.lua +++ b/lualib/lua_bayes_learn.lua @@ -51,6 +51,30 @@ exports.can_learn = function(task, is_spam, is_unlearn) end exports.autolearn = function(task, conf) + local function log_can_autolearn(verdict, score, threshold) + local from = task:get_from('smtp') + local mime_rcpts = 'undef' + local mr = task:get_recipients('mime') + if mr then + for _,r in ipairs(mr) do + if mime_rcpts == 'undef' then + mime_rcpts = r.addr + else + mime_rcpts = mime_rcpts .. ',' .. r.addr + end + end + end + + lua_util.debugm(N, task, 'id: %s, from: <%s>: can autolearn %s: score %s %s %s, mime_rcpts: <%s>', + task:get_header('Message-Id') or '', + from and from[1].addr or 'undef', + verdict, + string.format("%.2f", score), + verdict == 'ham' and '<=' or verdict == 'spam' and '>=' or '/', + threshold, + mime_rcpts) + end + -- We have autolearn config so let's figure out what is requested local verdict,score = lua_util.get_task_verdict(task) local learn_spam,learn_ham = false, false @@ -65,14 +89,12 @@ exports.autolearn = function(task, conf) if conf.spam_threshold and conf.ham_threshold then if verdict == 'spam' then if conf.spam_threshold and score >= conf.spam_threshold then - lua_util.debugm(N, task, 'can autolearn spam: score %s >= %s', - score, conf.spam_threshold) + log_can_autolearn(verdict, score, conf.spam_threshold) learn_spam = true end elseif verdict == 'ham' then if conf.ham_threshold and score <= conf.ham_threshold then - lua_util.debugm(N, task, 'can autolearn ham: score %s <= %s', - score, conf.ham_threshold) + log_can_autolearn(verdict, score, conf.ham_threshold) learn_ham = true end end