commit d17fe6b: [Minor] Print failed stage when showing stat error
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Mar 11 12:42:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-03-11 12:40:03 +0000
URL: https://github.com/rspamd/rspamd/commit/d17fe6bfce3ff90d38ae641715d07a68ab171be6 (HEAD -> master)
[Minor] Print failed stage when showing stat error
---
src/libserver/task.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++-
src/libserver/task.h | 7 ++++++
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 972856f29..30bccb81b 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -819,7 +819,9 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
if (stat_error == NULL) {
g_set_error (&stat_error,
g_quark_from_static_string ("stat"), 500,
- "Unknown statistics error");
+ "Unknown statistics error, found on stage %s;"
+ " classifier: %s",
+ rspamd_task_stage_name (st), task->classifier);
}
if (stat_error->code >= 400) {
@@ -1701,4 +1703,71 @@ rspamd_task_set_finish_time (struct rspamd_task *task)
}
return FALSE;
+}
+
+const gchar *
+rspamd_task_stage_name (enum rspamd_task_stage stg)
+{
+ const gchar *ret = "unknown stage";
+
+ switch (stg) {
+ case RSPAMD_TASK_STAGE_CONNECT:
+ ret = "connect";
+ break;
+ case RSPAMD_TASK_STAGE_ENVELOPE:
+ ret = "envelope";
+ break;
+ case RSPAMD_TASK_STAGE_READ_MESSAGE:
+ ret = "read_message";
+ break;
+ case RSPAMD_TASK_STAGE_PRE_FILTERS:
+ ret = "prefilters";
+ break;
+ case RSPAMD_TASK_STAGE_PROCESS_MESSAGE:
+ ret = "process_message";
+ break;
+ case RSPAMD_TASK_STAGE_FILTERS:
+ ret = "filters";
+ break;
+ case RSPAMD_TASK_STAGE_CLASSIFIERS_PRE:
+ ret = "classifiers_pre";
+ break;
+ case RSPAMD_TASK_STAGE_CLASSIFIERS:
+ ret = "classifiers";
+ break;
+ case RSPAMD_TASK_STAGE_CLASSIFIERS_POST:
+ ret = "classifiers_post";
+ break;
+ case RSPAMD_TASK_STAGE_COMPOSITES:
+ ret = "composites";
+ break;
+ case RSPAMD_TASK_STAGE_POST_FILTERS:
+ ret = "postfilters";
+ break;
+ case RSPAMD_TASK_STAGE_LEARN_PRE:
+ ret = "learn_pre";
+ break;
+ case RSPAMD_TASK_STAGE_LEARN:
+ ret = "learn";
+ break;
+ case RSPAMD_TASK_STAGE_LEARN_POST:
+ ret = "learn_post";
+ break;
+ case RSPAMD_TASK_STAGE_COMPOSITES_POST:
+ ret = "composites_post";
+ break;
+ case RSPAMD_TASK_STAGE_IDEMPOTENT:
+ ret = "idempotent";
+ break;
+ case RSPAMD_TASK_STAGE_DONE:
+ ret = "done";
+ break;
+ case RSPAMD_TASK_STAGE_REPLIED:
+ ret = "replied";
+ break;
+ default:
+ break;
+ }
+
+ return ret;
}
\ No newline at end of file
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 684f5c2c0..b97f91eb4 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -357,4 +357,11 @@ gdouble* rspamd_task_profile_get (struct rspamd_task *task, const gchar *key);
*/
gboolean rspamd_task_set_finish_time (struct rspamd_task *task);
+/**
+ * Returns task processing stage name
+ * @param stg
+ * @return
+ */
+const gchar *rspamd_task_stage_name (enum rspamd_task_stage stg);
+
#endif /* TASK_H_ */
More information about the Commits
mailing list