diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-29 13:16:52 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-29 13:16:52 +0100 |
commit | 119e4424924fc8a047e26cc01031065836109ce1 (patch) | |
tree | e8beb73f99f7a68e46170b04e631123ef4156842 /src/libstat | |
parent | c34210bf492cb7621da2b1c287799aa35b37515c (diff) | |
download | rspamd-119e4424924fc8a047e26cc01031065836109ce1.tar.gz rspamd-119e4424924fc8a047e26cc01031065836109ce1.zip |
More logging updates.
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/learn_cache/sqlite3_cache.c | 4 | ||||
-rw-r--r-- | src/libstat/stat_config.c | 8 | ||||
-rw-r--r-- | src/libstat/stat_internal.h | 1 | ||||
-rw-r--r-- | src/libstat/stat_process.c | 32 | ||||
-rw-r--r-- | src/libstat/tokenizers/osb.c | 14 |
5 files changed, 33 insertions, 26 deletions
diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c index ebfb5510c..0b2aa5ed8 100644 --- a/src/libstat/learn_cache/sqlite3_cache.c +++ b/src/libstat/learn_cache/sqlite3_cache.c @@ -167,7 +167,7 @@ rspamd_stat_cache_sqlite3_init(struct rspamd_stat_ctx *ctx, sqlite = rspamd_sqlite3_open_or_create (dbpath, create_tables_sql, &err); if (sqlite == NULL) { - msg_err ("cannot open sqlite3 cache: %e", err); + msg_err_config ("cannot open sqlite3 cache: %e", err); g_error_free (err); err = NULL; } @@ -178,7 +178,7 @@ rspamd_stat_cache_sqlite3_init(struct rspamd_stat_ctx *ctx, RSPAMD_STAT_CACHE_MAX, &err); if (new->prstmt == NULL) { - msg_err ("cannot open sqlite3 cache: %e", err); + msg_err_config ("cannot open sqlite3 cache: %e", err); g_error_free (err); err = NULL; sqlite3_close (sqlite); diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index 9e65b68a5..00baaa059 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -106,17 +106,18 @@ rspamd_stat_init (struct rspamd_config *cfg) stat_ctx->tokenizers_count = G_N_ELEMENTS (stat_tokenizers); stat_ctx->caches = stat_caches; stat_ctx->caches_count = G_N_ELEMENTS (stat_caches); + stat_ctx->cfg = cfg; /* Init backends */ for (i = 0; i < stat_ctx->backends_count; i ++) { stat_ctx->backends[i].ctx = stat_ctx->backends[i].init (stat_ctx, cfg); - msg_debug ("added backend %s", stat_ctx->backends[i].name); + msg_debug_config ("added backend %s", stat_ctx->backends[i].name); } /* Init caches */ for (i = 0; i < stat_ctx->caches_count; i ++) { stat_ctx->caches[i].ctx = stat_ctx->caches[i].init (stat_ctx, cfg); - msg_debug ("added cache %s", stat_ctx->caches[i].name); + msg_debug_config ("added cache %s", stat_ctx->caches[i].name); } } @@ -124,13 +125,14 @@ void rspamd_stat_close (void) { guint i; + struct rspamd_config *cfg = stat_ctx->cfg; g_assert (stat_ctx != NULL); for (i = 0; i < stat_ctx->backends_count; i ++) { if (stat_ctx->backends[i].close != NULL) { stat_ctx->backends[i].close (stat_ctx->backends[i].ctx); - msg_debug ("closed backend %s", stat_ctx->backends[i].name); + msg_debug_config ("closed backend %s", stat_ctx->backends[i].name); } } } diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h index e70fc298a..c049486fe 100644 --- a/src/libstat/stat_internal.h +++ b/src/libstat/stat_internal.h @@ -93,6 +93,7 @@ struct rspamd_stat_ctx { guint caches_count; guint statfiles; + struct rspamd_config *cfg; }; typedef enum rspamd_learn_cache_result { diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 776399fbc..32367f9c4 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -76,7 +76,7 @@ rspamd_stat_tokenize_header (struct rspamd_task *task, } } - msg_debug ("added stat tokens for header '%s'", name); + msg_debug_task ("added stat tokens for header '%s'", name); } } @@ -121,7 +121,7 @@ rspamd_stat_tokenize_parts_metadata (struct rspamd_task *task, g_array_append_val (ar, elt); } - msg_debug ("added stat tokens for image '%s'", img->html_image->src); + msg_debug_task ("added stat tokens for image '%s'", img->html_image->src); } cur = g_list_next (cur); @@ -137,7 +137,7 @@ rspamd_stat_tokenize_parts_metadata (struct rspamd_task *task, if (elt.begin) { elt.len = strlen (elt.begin); - msg_debug ("added stat tokens for mime boundary '%s'", elt.begin); + msg_debug_task ("added stat tokens for mime boundary '%s'", elt.begin); g_array_append_val (ar, elt); } } @@ -150,13 +150,13 @@ rspamd_stat_tokenize_parts_metadata (struct rspamd_task *task, if (tp->language != NULL && tp->language[0] != '\0') { elt.begin = (gchar *)tp->language; elt.len = strlen (elt.begin); - msg_debug ("added stat tokens for part language '%s'", elt.begin); + msg_debug_task ("added stat tokens for part language '%s'", elt.begin); g_array_append_val (ar, elt); } if (tp->real_charset != NULL) { elt.begin = (gchar *)tp->real_charset; elt.len = strlen (elt.begin); - msg_debug ("added stat tokens for part charset '%s'", elt.begin); + msg_debug_task ("added stat tokens for part charset '%s'", elt.begin); g_array_append_val (ar, elt); } } @@ -210,7 +210,7 @@ rspamd_stat_process_tokenize (struct rspamd_stat_ctx *st_ctx, } if (pdiff != NULL && *pdiff > similarity_treshold) { - msg_debug ("message has two common parts (%d%%), so skip the last one", + msg_debug_task ("message has two common parts (%d%%), so skip the last one", *pdiff); break; } @@ -288,8 +288,10 @@ preprocess_init_stat_token (gpointer k, gpointer v, gpointer d) struct rspamd_classifier_runtime *cl_runtime; struct rspamd_token_result *res; GList *cur, *curst; + struct rspamd_task *task; gint i = 0; + task = cbdata->task; t->results = g_array_sized_new (FALSE, TRUE, sizeof (struct rspamd_token_result), cbdata->results_count); g_array_set_size (t->results, cbdata->results_count); @@ -304,7 +306,7 @@ preprocess_init_stat_token (gpointer k, gpointer v, gpointer d) if (cl_runtime->clcf->min_tokens > 0 && (guint32)g_tree_nnodes (cbdata->tok->tokens) < cl_runtime->clcf->min_tokens) { /* Skip this classifier */ - msg_debug ("<%s> contains less tokens than required for %s classifier: " + msg_debug_task ("<%s> contains less tokens than required for %s classifier: " "%ud < %ud", cbdata->task->message_id, cl_runtime->clcf->name, g_tree_nnodes (cbdata->tok->tokens), cl_runtime->clcf->min_tokens); @@ -328,7 +330,7 @@ preprocess_init_stat_token (gpointer k, gpointer v, gpointer d) if (cl_runtime->clcf->max_tokens > 0 && cl_runtime->processed_tokens > cl_runtime->clcf->max_tokens) { - msg_debug ("<%s> contains more tokens than allowed for %s classifier: " + msg_debug_task ("<%s> contains more tokens than allowed for %s classifier: " "%ud > %ud", cbdata->task, cl_runtime->clcf->name, cl_runtime->processed_tokens, cl_runtime->clcf->max_tokens); @@ -495,7 +497,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, cl_runtime->start_pos = start_pos; cl_runtime->end_pos = end_pos; - msg_debug ("added runtime for %s classifier from %ud to %ud", + msg_debug_task ("added runtime for %s classifier from %ud to %ud", clcf->name, start_pos, end_pos); start_pos = end_pos; @@ -603,9 +605,11 @@ rspamd_stat_learn_token (gpointer k, gpointer v, gpointer d) struct rspamd_statfile_runtime *st_runtime; struct rspamd_classifier_runtime *cl_runtime; struct rspamd_token_result *res; + struct rspamd_task *task; GList *cur, *curst; gint i = 0; + task = cbdata->task; cur = g_list_first (cbdata->classifier_runtimes); while (cur) { @@ -614,7 +618,7 @@ rspamd_stat_learn_token (gpointer k, gpointer v, gpointer d) if (cl_runtime->clcf->min_tokens > 0 && (guint32)g_tree_nnodes (cbdata->tok->tokens) < cl_runtime->clcf->min_tokens) { /* Skip this classifier */ - msg_debug ("<%s> contains less tokens than required for %s classifier: " + msg_debug_task ("<%s> contains less tokens than required for %s classifier: " "%ud < %ud", cbdata->task->message_id, cl_runtime->clcf->name, g_tree_nnodes (cbdata->tok->tokens), cl_runtime->clcf->min_tokens); @@ -634,7 +638,7 @@ rspamd_stat_learn_token (gpointer k, gpointer v, gpointer d) if (cl_runtime->clcf->max_tokens > 0 && cl_runtime->processed_tokens > cl_runtime->clcf->max_tokens) { - msg_debug ("<%s> contains more tokens than allowed for %s classifier: " + msg_debug_task ("<%s> contains more tokens than allowed for %s classifier: " "%ud > %ud", cbdata->task, cl_runtime->clcf->name, cl_runtime->processed_tokens, cl_runtime->clcf->max_tokens); @@ -710,7 +714,7 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L, if (cl_ctx != NULL) { if (cl_run->cl->learn_spam_func (cl_ctx, cl_run->tok->tokens, cl_run, task, spam, err)) { - msg_debug ("learned %s classifier %s", spam ? "spam" : "ham", + msg_debug_task ("learned %s classifier %s", spam ? "spam" : "ham", cl_run->clcf->name); ret = RSPAMD_STAT_PROCESS_OK; learned = TRUE; @@ -732,14 +736,14 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L, nrev = cl_run->backend->dec_learns (task, st_run->backend_runtime, cl_run->backend->ctx); - msg_debug ("unlearned %s, new revision: %ul", + msg_debug_task ("unlearned %s, new revision: %ul", st_run->st->symbol, nrev); } else { nrev = cl_run->backend->inc_learns (task, st_run->backend_runtime, cl_run->backend->ctx); - msg_debug ("learned %s, new revision: %ul", + msg_debug_task ("learned %s, new revision: %ul", st_run->st->symbol, nrev); } diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index 10d7649e4..690a7ab5b 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -135,7 +135,7 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool, } } else { - msg_warn ("siphash cannot be used without key"); + msg_warn_pool ("siphash cannot be used without key"); } } @@ -151,7 +151,7 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool, if (elt != NULL && ucl_object_type (elt) == UCL_INT) { cf->window_size = ucl_object_toint (elt); if (cf->window_size > DEFAULT_FEATURE_WINDOW_SIZE * 4) { - msg_err ("too large window size: %d", cf->window_size); + msg_err_pool ("too large window size: %d", cf->window_size); cf->window_size = DEFAULT_FEATURE_WINDOW_SIZE; } } @@ -177,8 +177,8 @@ rspamd_tokenizer_osb_get_config (rspamd_mempool_t *pool, } if (osb_cf->ht == RSPAMD_OSB_HASH_SIPHASH) { - msg_info ("siphash key is not stored into statfiles, so you'd need to " - "keep it inside the configuration"); + msg_info_pool ("siphash key is not stored into statfiles, so you'd " + "need to keep it inside the configuration"); } memset (osb_cf->sk, 0, sizeof (osb_cf->sk)); @@ -358,9 +358,9 @@ rspamd_tokenizer_osb_load_config (rspamd_mempool_t *pool, if (osb_cf->ht != RSPAMD_OSB_HASH_COMPAT) { /* Trying to load incompatible configuration */ - msg_err ("cannot load tokenizer configuration from a legacy statfile," - " maybe you have forgotten to set 'compat' option in the " - "tokenizer configuration"); + msg_err_pool ("cannot load tokenizer configuration from a legacy " + "statfile; maybe you have forgotten to set 'compat' option" + " in the tokenizer configuration"); return FALSE; } |