aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-18 15:05:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-18 15:05:07 +0100
commit36e1c0b7a60a78e6c69cc21cc2809901c5d95af9 (patch)
treedd3f7d6ae2878f296e734b3eeaf3dde41cd9cec7 /src
parent181b3ee7de5f4c986139982f8ffd2d3ef0c3b899 (diff)
downloadrspamd-36e1c0b7a60a78e6c69cc21cc2809901c5d95af9.tar.gz
rspamd-36e1c0b7a60a78e6c69cc21cc2809901c5d95af9.zip
[Minor] Neural: Improve logging
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/neural.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua
index 8bec374fc..0b93cd4a7 100644
--- a/src/plugins/lua/neural.lua
+++ b/src/plugins/lua/neural.lua
@@ -967,21 +967,27 @@ local function maybe_train_existing_ann(worker, ev_base, rule, set, profiles)
ann_key)
-- Create continuation closure
- local redis_len_cb_gen = function(cont_cb, what)
+ local redis_len_cb_gen = function(cont_cb, what, is_final)
return function(err, data)
if err then
rspamd_logger.errx(rspamd_config,
'cannot get ANN %s trains %s from redis: %s', what, ann_key, err)
elseif data and type(data) == 'number' or type(data) == 'string' then
if tonumber(data) and tonumber(data) >= rule.train.max_trains then
- rspamd_logger.debugm(N, rspamd_config,
- 'ANN %s has %s %s learn vectors (%s required)',
- ann_key, tonumber(data), what, rule.train.max_trains)
+ if is_final then
+ rspamd_logger.debugm(N, rspamd_config,
+ 'can start ANN %s learn as it has %s learn vectors; %s required, after checking %s vectors',
+ ann_key, tonumber(data), rule.train.max_trains, what)
+ else
+ rspamd_logger.debugm(N, rspamd_config,
+ 'checked %s vectors in ANN %s: %s vectors; %s required, need to check other class vectors',
+ what, ann_key, tonumber(data), rule.train.max_trains)
+ end
cont_cb()
else
rspamd_logger.debugm(N, rspamd_config,
- 'no need to learn ANN %s %s %s learn vectors (%s required)',
- ann_key, tonumber(data), what, rule.train.max_trains)
+ 'cannot learn ANN %s now: there are not enough %s learn vectors (has %s vectors; %s required)',
+ ann_key, what, tonumber(data), rule.train.max_trains)
end
end
end
@@ -1002,7 +1008,7 @@ local function maybe_train_existing_ann(worker, ev_base, rule, set, profiles)
rule.redis,
nil,
false, -- is write
- redis_len_cb_gen(initiate_train, 'ham'), --callback
+ redis_len_cb_gen(initiate_train, 'ham', true), --callback
'LLEN', -- command
{ann_key .. '_ham'}
)
@@ -1013,7 +1019,7 @@ local function maybe_train_existing_ann(worker, ev_base, rule, set, profiles)
rule.redis,
nil,
false, -- is write
- redis_len_cb_gen(check_ham_len, 'spam'), --callback
+ redis_len_cb_gen(check_ham_len, 'spam', false), --callback
'LLEN', -- command
{ann_key .. '_spam'}
)