From: Vsevolod Stakhov Date: Mon, 31 Aug 2015 17:22:10 +0000 (+0100) Subject: Update other C module for the new logger. X-Git-Tag: 1.0.0~121 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e3395816d88a79a7fa22ae2e1b364f5cfa099777;p=rspamd.git Update other C module for the new logger. --- diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c index 2cd12b68d..9c7362b35 100644 --- a/src/plugins/chartable.c +++ b/src/plugins/chartable.c @@ -95,7 +95,7 @@ chartable_module_config (struct rspamd_config *cfg) if ((value = rspamd_config_get_module_opt (cfg, "chartable", "threshold")) != NULL) { if (!ucl_obj_todouble_safe (value, &chartable_module_ctx->threshold)) { - msg_warn ("invalid numeric value"); + msg_warn_config ("invalid numeric value"); chartable_module_ctx->threshold = DEFAULT_THRESHOLD; } } diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index 2fa5610f9..e6c88da52 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -180,7 +180,7 @@ dkim_module_config (struct rspamd_config *cfg) if (!rspamd_map_add (cfg, ucl_obj_tostring (value), "DKIM domains", rspamd_kv_list_read, rspamd_kv_list_fin, (void **)&dkim_module_ctx->dkim_domains)) { - msg_warn ("cannot load dkim domains list from %s", + msg_warn_config ("cannot load dkim domains list from %s", ucl_obj_tostring (value)); } else { @@ -192,7 +192,7 @@ dkim_module_config (struct rspamd_config *cfg) if (!rspamd_map_add (cfg, ucl_obj_tostring (value), "DKIM domains", rspamd_kv_list_read, rspamd_kv_list_fin, (void **)&dkim_module_ctx->dkim_domains)) { - msg_warn ("cannot load dkim domains list from %s", + msg_warn_config ("cannot load dkim domains list from %s", ucl_obj_tostring (value)); } else { @@ -223,7 +223,7 @@ dkim_module_config (struct rspamd_config *cfg) } if (dkim_module_ctx->trusted_only && !got_trusted) { - msg_err ( + msg_err_config ( "trusted_only option is set and no trusted domains are defined; disabling dkim module completely as it is useless in this case"); } else { @@ -255,7 +255,7 @@ dkim_module_config (struct rspamd_config *cfg) #ifndef HAVE_OPENSSL - msg_warn ( + msg_warn_config ( "openssl is not found so dkim rsa check is disabled, only check body hash, it is NOT safe to trust these results"); #endif } @@ -311,6 +311,7 @@ dkim_module_check (struct dkim_check_result *res) gboolean all_done = TRUE, got_allow = FALSE; const gchar *strict_value; struct dkim_check_result *first, *cur, *sel = NULL; + struct rspamd_task *task = res->task; first = res->first; @@ -320,7 +321,7 @@ dkim_module_check (struct dkim_check_result *res) } if (cur->key != NULL && cur->res == -1) { - msg_debug ("check dkim signature for %s domain from %s", + msg_debug_task ("check dkim signature for %s domain from %s", cur->ctx->domain, cur->ctx->dns_key); cur->res = rspamd_dkim_check (cur->ctx, cur->key, cur->task); @@ -443,11 +444,11 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused) FALSE); if (hlist != NULL) { /* Check whitelist */ - msg_debug ("dkim signature found"); + msg_debug_task ("dkim signature found"); if (radix_find_compressed_addr (dkim_module_ctx->whitelist_ip, task->from_addr) == RADIX_NO_VALUE) { /* Parse signature */ - msg_debug ("create dkim signature"); + msg_debug_task ("create dkim signature"); while (hlist != NULL) { rh = (struct raw_header *)hlist->data; @@ -474,12 +475,13 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused) &err); if (ctx == NULL) { if (err != NULL) { - msg_info ("<%s> cannot parse DKIM context: %s", + msg_info_task ("<%s> cannot parse DKIM context: %s", task->message_id, err->message); g_error_free (err); } else { - msg_info ("<%s> cannot parse DKIM context: unknown error", + msg_info_task ("<%s> cannot parse DKIM context: " + "unknown error", task->message_id); } @@ -495,7 +497,8 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused) (dkim_module_ctx->dkim_domains == NULL || g_hash_table_lookup (dkim_module_ctx->dkim_domains, ctx->domain) == NULL)) { - msg_debug ("skip dkim check for %s domain", ctx->domain); + msg_debug_task ("skip dkim check for %s domain", + ctx->domain); hlist = g_list_next (hlist); continue; diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 4e969bfd9..ef10056e5 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -151,7 +151,7 @@ parse_flags (struct fuzzy_rule *rule, const gchar *sym = NULL; if (val->type == UCL_STRING) { - msg_err ( + msg_err_config ( "string mappings are deprecated and no longer supported, use new style configuration"); } else if (val->type == UCL_OBJECT) { @@ -183,15 +183,15 @@ parse_flags (struct fuzzy_rule *rule, cb_id); } else { - msg_err ("fuzzy_map parameter has no flag definition"); + msg_err_config ("fuzzy_map parameter has no flag definition"); } } else { - msg_err ("fuzzy_map parameter has no symbol definition"); + msg_err_config ("fuzzy_map parameter has no symbol definition"); } } else { - msg_err ("fuzzy_map parameter is of an unsupported type"); + msg_err_config ("fuzzy_map parameter is of an unsupported type"); } } @@ -307,7 +307,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id const char *k = NULL; if (obj->type != UCL_OBJECT) { - msg_err ("invalid rule definition"); + msg_err_config ("invalid rule definition"); return -1; } @@ -380,7 +380,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id rule->shingles_key->len = 16; if (rspamd_upstreams_count (rule->servers) == 0) { - msg_err ("no servers defined for fuzzy rule with symbol: %s", + msg_err_config ("no servers defined for fuzzy rule with symbol: %s", rule->symbol); return -1; } @@ -503,7 +503,7 @@ fuzzy_check_module_config (struct rspamd_config *cfg) } if (fuzzy_module_ctx->fuzzy_rules == NULL) { - msg_warn ("fuzzy module is enabled but no rules are defined"); + msg_warn_config ("fuzzy module is enabled but no rules are defined"); } return res; @@ -589,7 +589,8 @@ fuzzy_cmd_from_text_part (struct fuzzy_rule *rule, } blake2b_final (&st, shcmd->basic.digest, sizeof (shcmd->basic.digest)); - msg_debug ("loading shingles with key %*xs", 16, rule->shingles_key->str); + msg_debug_pool ("loading shingles with key %*xs", 16, + rule->shingles_key->str); sh = rspamd_shingles_generate (words, rule->shingles_key->str, pool, rspamd_shingles_default_filter, NULL); @@ -739,6 +740,7 @@ fuzzy_io_callback (gint fd, short what, void *arg) { struct fuzzy_client_session *session = arg; const struct rspamd_fuzzy_reply *rep; + struct rspamd_task *task; struct fuzzy_mapping *map; guchar buf[2048], *p; const gchar *symbol; @@ -746,6 +748,8 @@ fuzzy_io_callback (gint fd, short what, void *arg) double nval; gint ret = -1; + task = session->task; + if (what == EV_WRITE) { if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { ret = -1; @@ -783,7 +787,7 @@ fuzzy_io_callback (gint fd, short what, void *arg) if (rep->prob > 0.5) { nval = fuzzy_normalize (rep->value, session->rule->max_score); nval *= rep->prob; - msg_info ( + msg_info_task ( "<%s>, found fuzzy hash with weight: %.2f, in list: %s:%d%s", session->task->message_id, nval, @@ -818,7 +822,7 @@ fuzzy_io_callback (gint fd, short what, void *arg) return; } else if (ret == -1) { - msg_err ("got error on IO with server %s, %d, %s", + msg_err_task ("got error on IO with server %s, %d, %s", rspamd_upstream_name (session->server), errno, strerror (errno)); @@ -839,11 +843,14 @@ fuzzy_learn_callback (gint fd, short what, void *arg) struct fuzzy_learn_session *session = arg; const struct rspamd_fuzzy_reply *rep; struct fuzzy_mapping *map; + struct rspamd_task *task; guchar buf[2048], *p; const gchar *symbol; gint r; gint ret = 0; + task = session->task; + if (what == EV_WRITE) { /* Send commands to storage */ if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { @@ -863,7 +870,7 @@ fuzzy_learn_callback (gint fd, short what, void *arg) } else if (what == EV_READ) { if ((r = read (fd, buf, sizeof (buf) - 1)) == -1) { - msg_info ("cannot process fuzzy hash for message <%s>", + msg_info_task ("cannot process fuzzy hash for message <%s>", session->task->message_id); if (*(session->err) == NULL) { g_set_error (session->err, @@ -888,14 +895,17 @@ fuzzy_learn_callback (gint fd, short what, void *arg) } if (rep->prob > 0.5) { - msg_info ("processed fuzzy hash, list: %s:%d for message <%s>", + msg_info_task ("processed fuzzy hash, list: %s:%d for " + "message <%s>", symbol, rep->flag, session->task->message_id); ret = 1; } else { - msg_info ("cannot process fuzzy hash for message <%s>, list %s:%d", + msg_info_task ("cannot process fuzzy hash for message " + "<%s>, " + "list %s:%d", session->task->message_id, symbol, rep->flag); @@ -923,7 +933,7 @@ fuzzy_learn_callback (gint fd, short what, void *arg) return; } else if (ret == -1) { - msg_err ("got error in IO with server %s, %d, %s", + msg_err_task ("got error in IO with server %s, %d, %s", rspamd_upstream_name (session->server), errno, strerror (errno)); rspamd_upstream_fail (session->server); } @@ -972,20 +982,21 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, /* Check length of part */ if (fuzzy_module_ctx->min_bytes > part->content->len) { - msg_info ("<%s>, part is shorter than %d symbols, skip fuzzy check", + msg_info_task ("<%s>, part is shorter than %d symbols, skip fuzzy " + "check", task->message_id, fuzzy_module_ctx->min_bytes); continue; } if (part->words == NULL || part->words->len == 0) { - msg_info ("<%s>, part hash empty, skip fuzzy check", + msg_info_task ("<%s>, part hash empty, skip fuzzy check", task->message_id, fuzzy_module_ctx->min_hash_len); continue; } if (fuzzy_module_ctx->min_hash_len != 0 && part->words->len < fuzzy_module_ctx->min_hash_len) { - msg_info ( + msg_info_task ( "<%s>, part hash is shorter than %d symbols, skip fuzzy check", task->message_id, fuzzy_module_ctx->min_hash_len); @@ -1083,7 +1094,7 @@ register_fuzzy_client_call (struct rspamd_task *task, if (selected) { if ((sock = rspamd_inet_address_connect (rspamd_upstream_addr (selected), SOCK_DGRAM, TRUE)) == -1) { - msg_warn ("cannot connect to %s, %d, %s", + msg_warn_task ("cannot connect to %s, %d, %s", rspamd_upstream_name (selected), errno, strerror (errno)); @@ -1123,7 +1134,7 @@ fuzzy_symbol_callback (struct rspamd_task *task, void *unused) if (fuzzy_module_ctx->whitelist) { if (radix_find_compressed_addr (fuzzy_module_ctx->whitelist, task->from_addr) != RADIX_NO_VALUE) { - msg_info ("<%s>, address %s is whitelisted, skip fuzzy check", + msg_info_task ("<%s>, address %s is whitelisted, skip fuzzy check", task->message_id, rspamd_inet_address_to_string (task->from_addr)); return; @@ -1215,7 +1226,8 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent, err = rspamd_mempool_alloc0 (task->task_pool, sizeof (GError *)); r = rspamd_message_parse (task); if (r == -1) { - msg_warn ("<%s>: cannot process message for fuzzy", task->message_id); + msg_warn_task ("<%s>: cannot process message for fuzzy", + task->message_id); rspamd_task_free (task, FALSE); rspamd_controller_send_error (conn_ent, 400, "Message processing error"); @@ -1256,7 +1268,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent, } if (res == -1) { - msg_warn ("<%s>: cannot send fuzzy request: %s", task->message_id, + msg_warn_task ("<%s>: cannot send fuzzy request: %s", task->message_id, strerror (errno)); rspamd_controller_send_error (conn_ent, 400, "Message sending error"); rspamd_task_free (task, FALSE); @@ -1264,12 +1276,14 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent, } else if (!processed) { if (rules) { - msg_warn ("<%s>: no content to generate fuzzy", task->message_id); + msg_warn_task ("<%s>: no content to generate fuzzy", + task->message_id); rspamd_controller_send_error (conn_ent, 404, "No content to generate fuzzy for flag %d", flag); } else { - msg_warn ("<%s>: no fuzzy rules found for flag %d", task->message_id, + msg_warn_task ("<%s>: no fuzzy rules found for flag %d", + task->message_id, flag); rspamd_controller_send_error (conn_ent, 404, "No fuzzy rules matched for flag %d", flag); diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 179446d3c..16f941364 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -78,7 +78,8 @@ read_regexp_expression (rspamd_mempool_t * pool, if (!rspamd_parse_expression (line, 0, &mime_expr_subr, cfg, pool, &err, &e)) { - msg_warn ("%s = \"%s\" is invalid regexp expression: %e", symbol, line, + msg_warn_pool ("%s = \"%s\" is invalid regexp expression: %e", symbol, + line, err); g_error_free (err); @@ -119,7 +120,7 @@ regexp_module_config (struct rspamd_config *cfg) sec = ucl_object_find_key (cfg->rcl_obj, "regexp"); if (sec == NULL) { - msg_err ("regexp module enabled, but no rules are defined"); + msg_err_config ("regexp module enabled, but no rules are defined"); return TRUE; } @@ -133,7 +134,7 @@ regexp_module_config (struct rspamd_config *cfg) } else if (g_ascii_strncasecmp (ucl_object_key (value), "max_threads", sizeof ("max_threads") - 1) == 0) { - msg_warn ("regexp module is now single threaded, max_threads is ignored"); + msg_warn_config ("regexp module is now single threaded, max_threads is ignored"); } else if (value->type == UCL_STRING) { cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool, @@ -194,7 +195,7 @@ regexp_module_config (struct rspamd_config *cfg) } } else { - msg_err ( + msg_err_config ( "no callback/expression defined for regexp symbol: " "%s", ucl_object_key (value)); } @@ -261,7 +262,7 @@ regexp_module_config (struct rspamd_config *cfg) } } else { - msg_warn ("unknown type of attribute %s for regexp module", + msg_warn_config ("unknown type of attribute %s for regexp module", ucl_object_key (value)); } } @@ -311,7 +312,7 @@ static gboolean rspamd_lua_call_expression_func( lua_pushboolean (L, (gboolean) GPOINTER_TO_SIZE(arg->data)); break; default: - msg_err("cannot pass custom params to lua function"); + msg_err_task ("cannot pass custom params to lua function"); return FALSE; } } @@ -320,7 +321,7 @@ static gboolean rspamd_lua_call_expression_func( } if (lua_pcall (L, nargs + 1, 1, 0) != 0) { - msg_info("call to lua function failed: %s", lua_tostring (L, -1)); + msg_info_task ("call to lua function failed: %s", lua_tostring (L, -1)); return FALSE; } pop++; @@ -332,7 +333,7 @@ static gboolean rspamd_lua_call_expression_func( *res = lua_toboolean (L, -1); } else { - msg_info("lua function must return a boolean"); + msg_info_task ("lua function must return a boolean"); } lua_pop (L, pop); @@ -353,7 +354,8 @@ process_regexp_item (struct rspamd_task *task, void *user_data) res = FALSE; if (!rspamd_lua_call_expression_func (item->lua_function, task, NULL, &res)) { - msg_err ("error occurred when checking symbol %s", item->symbol); + msg_err_task ("error occurred when checking symbol %s", + item->symbol); } } else { @@ -362,7 +364,7 @@ process_regexp_item (struct rspamd_task *task, void *user_data) res = rspamd_process_expression (item->expr, 0, task); } else { - msg_warn ("FIXME: %s symbol is broken with new expressions", + msg_warn_task ("FIXME: %s symbol is broken with new expressions", item->symbol); } } diff --git a/src/plugins/spf.c b/src/plugins/spf.c index eb50ab2b9..70c298a7d 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -244,7 +244,7 @@ spf_check_element (struct spf_addr *addr, struct rspamd_task *task) /* Compare the first bytes */ bmask = mask / CHAR_BIT; if (bmask > addrlen) { - msg_info ("bad mask length: %d", mask); + msg_info_task ("bad mask length: %d", mask); } else if (memcmp (s, d, bmask) == 0) { @@ -362,7 +362,8 @@ spf_symbol_callback (struct rspamd_task *task, void *unused) } else { if (!resolve_spf (task, spf_plugin_callback)) { - msg_info ("cannot make spf request for [%s]", task->message_id); + msg_info_task ("cannot make spf request for [%s]", + task->message_id); } else { rspamd_session_add_event (task->s, spf_plugin_fin, NULL,