]> source.dussan.org Git - rspamd.git/commitdiff
* Add logging for fuzzy checks
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 2 Aug 2010 12:46:28 +0000 (16:46 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 2 Aug 2010 12:46:28 +0000 (16:46 +0400)
* Add logging for learning

src/controller.c
src/plugins/fuzzy_check.c

index 424db1271ac6f3a46ceda8f19cc68c3c88c4af92..6ef9f7e08f48d57e9d1c98aa628e7bdc7c3b3206 100644 (file)
@@ -809,6 +809,7 @@ controller_read_socket (f_str_t * in, void *arg)
                /* Handle messages without text */
                if (tokens == NULL) {
                        i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn failed, no tokens can be extracted (no text data)" CRLF);
+                       msg_info ("learn failed for message <%s>, no tokens to extract", task->message_id);
                        free_task (task, FALSE);
                        if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
                                return FALSE;
@@ -821,8 +822,9 @@ controller_read_socket (f_str_t * in, void *arg)
                statfile = get_statfile_by_symbol (session->worker->srv->statfile_pool, session->learn_classifier,
                                                session->learn_symbol, &st, TRUE);
                if (statfile == NULL) {
+                       msg_info ("learn failed for message <%s>, no statfile found: %s", task->message_id, session->learn_symbol);
                        free_task (task, FALSE);
-                       i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn failed" CRLF);
+                       i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn failed, invalid symbol" CRLF);
                        if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
                                return FALSE;
                        }
@@ -842,7 +844,8 @@ controller_read_socket (f_str_t * in, void *arg)
                if (st->normalizer != NULL) {
                        sum = st->normalizer (session->cfg, sum, st->normalizer_data);
                }
-               
+               msg_info ("learn success for message <%s>, for statfile: %s, sum weight: %.2f",
+                               task->message_id, session->learn_symbol, sum);
                free_task (task, FALSE);
                i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn ok, sum weight: %.2f" CRLF, sum);
                if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
index 4567f62cf14cf3292c9b39998dc8ce197d379550..49b9b976e07bf3bb1501b001579766b7f4468ddc 100644 (file)
@@ -383,7 +383,8 @@ fuzzy_io_callback (int fd, short what, void *arg)
                                symbol = map->symbol;
                                nval = fuzzy_normalize (value, map->weight);
                        }
-
+                       msg_info ("<%s>, found fuzzy hash with weight: %.2f, in list: %d",
+                                       session->task->message_id, flag, nval);
                        rspamd_snprintf (buf, sizeof (buf), "%d: %d / %.2f", flag, value, nval);
                        insert_result (session->task, symbol, nval, g_list_prepend (NULL, 
                                                memory_pool_strdup (session->task->task_pool, buf)));
@@ -446,6 +447,7 @@ fuzzy_learn_callback (int fd, short what, void *arg)
                        goto err;
                }
                else if (buf[0] == 'O' && buf[1] == 'K') {
+                       msg_info ("added fuzzy hash for message <%s>", session->task->message_id);
                        r = rspamd_snprintf (buf, sizeof (buf), "OK" CRLF);
                        if (! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) {
                                return;
@@ -453,6 +455,7 @@ fuzzy_learn_callback (int fd, short what, void *arg)
                        goto ok;
                }
                else {
+                       msg_info ("cannot add fuzzy hash for message <%s>", session->task->message_id);
                        r = rspamd_snprintf (buf, sizeof (buf), "ERR" CRLF);
                        if (! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) {
                                return;
@@ -529,7 +532,8 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused)
        /* Check whitelist */
        if (fuzzy_module_ctx->whitelist && task->from_addr.s_addr != 0) {
                if (radix32tree_find (fuzzy_module_ctx->whitelist, ntohl ((uint32_t) task->from_addr.s_addr)) != RADIX_NO_VALUE) {
-                       msg_info ("address %s is whitelisted, skip fuzzy check", inet_ntoa (task->from_addr));
+                       msg_info ("<%s>, address %s is whitelisted, skip fuzzy check",
+                                       task->message_id, inet_ntoa (task->from_addr));
                        return;
                }
        }
@@ -546,7 +550,8 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused)
                /* Check length of hash */
                if (fuzzy_module_ctx->min_hash_len != 0 && 
                                strlen (part->fuzzy->hash_pipe) * part->fuzzy->block_size < fuzzy_module_ctx->min_hash_len) {
-                       msg_info ("part hash is shorter than %d symbols, skip fuzzy check", fuzzy_module_ctx->min_hash_len);
+                       msg_info ("<%s>, part hash is shorter than %d symbols, skip fuzzy check",
+                                       task->message_id, fuzzy_module_ctx->min_hash_len);
                        cur = g_list_next (cur);
                        continue;
                }