diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-28 11:39:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-28 11:39:16 +0100 |
commit | 8879db43df630625cb3fb86ff808f83d487ad484 (patch) | |
tree | 49d394477a21a91c4c75159c96f87819a4343536 | |
parent | 00135c8f9a8dda4fe3ccdfe8a05bea691e73930a (diff) | |
download | rspamd-8879db43df630625cb3fb86ff808f83d487ad484.tar.gz rspamd-8879db43df630625cb3fb86ff808f83d487ad484.zip |
[Minor] Improve stats errors reporting
-rw-r--r-- | src/libstat/stat_process.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 901d62a2b..24fcd7312 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -633,25 +633,25 @@ rspamd_stat_classifiers_learn (struct rspamd_stat_ctx *st_ctx, "<%s> contains more tokens than allowed for %s classifier: " "%d > %d", task->message_id, - cl->cfg->name, + sel->cfg->name, task->tokens->len, - cl->cfg->max_tokens); + sel->cfg->max_tokens); } else if (too_small) { g_set_error (err, rspamd_stat_quark (), 204, "<%s> contains less tokens than required for %s classifier: " "%d < %d", task->message_id, - cl->cfg->name, + sel->cfg->name, task->tokens->len, - cl->cfg->min_tokens); + sel->cfg->min_tokens); } else if (conditionally_skipped) { g_set_error (err, rspamd_stat_quark (), 204, "<%s> is skipped for %s classifier: " "%s", task->message_id, - cl->cfg->name, + sel->cfg->name, cond_str ? cond_str : "unknown reason"); } } @@ -698,6 +698,8 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx, if (bk_run == NULL) { /* XXX: must be error */ + msg_warn_task ("no runtime for backend %s; classifier %s; symbol %s", + st->backend->name, cl->cfg->name, st->stcf->symbol); continue; } @@ -709,10 +711,9 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx, } if (!st->backend->learn_tokens (task, task->tokens, id, bk_run)) { - if (err && *err == NULL) { - g_set_error (err, rspamd_stat_quark (), 500, "Cannot push " - "learned results to the backend"); - } + g_set_error (err, rspamd_stat_quark (), 500, + "Cannot push " + "learned results to the backend"); res = FALSE; goto end; @@ -844,11 +845,23 @@ rspamd_stat_learn (struct rspamd_task *task, /* Process classifiers */ if (!rspamd_stat_classifiers_learn (st_ctx, task, classifier, spam, err)) { + if (err && *err == NULL) { + g_set_error (err, rspamd_stat_quark (), 500, + "Unknown statistics error, found when learning classifiers;" + " classifier: %s", + task->classifier); + } return RSPAMD_STAT_PROCESS_ERROR; } /* Process backends */ if (!rspamd_stat_backends_learn (st_ctx, task, classifier, spam, err)) { + if (err && *err == NULL) { + g_set_error (err, rspamd_stat_quark (), 500, + "Unknown statistics error, found when storing data on backend;" + " classifier: %s", + task->classifier); + } return RSPAMD_STAT_PROCESS_ERROR; } } |