diff options
-rw-r--r-- | src/libmime/lang_detection.c | 6 | ||||
-rw-r--r-- | src/libserver/fuzzy_backend_redis.c | 6 | ||||
-rw-r--r-- | src/libstat/classifiers/lua_classifier.c | 6 | ||||
-rw-r--r-- | src/libutil/logger.c | 9 | ||||
-rw-r--r-- | src/libutil/logger.h | 37 | ||||
-rw-r--r-- | src/libutil/map.c | 6 | ||||
-rw-r--r-- | src/libutil/map_private.h | 6 | ||||
-rw-r--r-- | src/libutil/radix.c | 6 |
8 files changed, 52 insertions, 30 deletions
diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index 6b71e45a1..c31d0d8fc 100644 --- a/src/libmime/lang_detection.c +++ b/src/libmime/lang_detection.c @@ -56,11 +56,13 @@ struct rspamd_lang_detector { gsize short_text_limit; }; -#define msg_debug_lang_det(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "langdet", task->task_pool->tag.uid, \ +#define msg_debug_lang_det(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_langdet_log_id, "langdet", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(langdet) + static guint rspamd_unigram_hash (gconstpointer key) { diff --git a/src/libserver/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend_redis.c index d9d1cc0a7..06f100132 100644 --- a/src/libserver/fuzzy_backend_redis.c +++ b/src/libserver/fuzzy_backend_redis.c @@ -41,11 +41,13 @@ "fuzzy_redis", session->backend->id, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_redis_session(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "fuzzy_redis", session->backend->id, \ +#define msg_debug_redis_session(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_fuzzy_redis_log_id, "fuzzy_redis", session->backend->id, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(fuzzy_redis) + struct rspamd_fuzzy_backend_redis { struct upstream_list *read_servers; struct upstream_list *write_servers; diff --git a/src/libstat/classifiers/lua_classifier.c b/src/libstat/classifiers/lua_classifier.c index 823f689d5..b76893920 100644 --- a/src/libstat/classifiers/lua_classifier.c +++ b/src/libstat/classifiers/lua_classifier.c @@ -39,11 +39,13 @@ static GHashTable *lua_classifiers = NULL; "luacl", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_luacl(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "luacl", task->task_pool->tag.uid, \ +#define msg_debug_luacl(...) rspamd_conditional_debug_fast (NULL, task->from_addr, \ + rspamd_luacl_log_id, "luacl", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(luacl) + gboolean lua_classifier_init (rspamd_mempool_t *pool, struct rspamd_classifier *cl) diff --git a/src/libutil/logger.c b/src/libutil/logger.c index d69c0f038..487ca2633 100644 --- a/src/libutil/logger.c +++ b/src/libutil/logger.c @@ -115,6 +115,12 @@ static void file_log_function (const gchar *module, gint log_level, const gchar *message, gpointer arg); +guint rspamd_task_log_id = (guint)-1; +RSPAMD_CONSTRUCTOR(rspamd_task_log_init) +{ + rspamd_task_log_id = rspamd_logger_add_debug_module("task"); +} + /** * Calculate checksum for log line (used for repeating logic) */ @@ -1358,6 +1364,7 @@ rspamd_logger_add_debug_module (const gchar *mname) m->mname = g_strdup (mname); m->id = rspamd_logger_allocate_mod_bit (); clrbit (log_modules->bitset, m->id); + g_hash_table_insert (log_modules->modules, m->mname, m); } return m->id; @@ -1383,7 +1390,7 @@ rspamd_logger_configure_modules (GHashTable *mods_enabled) while (g_hash_table_iter_next (&it, &k, &v)) { id = rspamd_logger_add_debug_module ((const gchar *)k); - + msg_info ("enable debugging for module %s (%d)", (const gchar *)k, id); setbit (log_modules->bitset, id); } }
\ No newline at end of file diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 3f3f28ef6..9b94c03ee 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -106,9 +106,9 @@ guint rspamd_logger_add_debug_module (const gchar *mod); * Macro to use for faster debug modules */ #define INIT_LOG_MODULE(mname) \ - static guint mname##_log_id = (guint)-1; \ - static RSPAMD_CONSTRUCTOR(mname##_log_init) { \ - mname##_log_id = rspamd_logger_add_debug_module(#mname); \ + static guint rspamd_##mname##_log_id = (guint)-1; \ + RSPAMD_CONSTRUCTOR(rspamd_##mname##_log_init) { \ + rspamd_##mname##_log_id = rspamd_logger_add_debug_module(#mname); \ } void rspamd_logger_configure_modules (GHashTable *mods_enabled); @@ -185,6 +185,8 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); /* Typical functions */ +extern guint rspamd_task_log_id; + /* Logging in postfix style */ #define msg_err(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ NULL, NULL, \ @@ -202,9 +204,10 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); NULL, NULL, \ G_STRFUNC, \ __VA_ARGS__) -#define debug_task(...) rspamd_conditional_debug (NULL, \ + +#define debug_task(...) rspamd_conditional_debug_fast (NULL, \ task->from_addr, \ - "task", task->task_pool->tag.uid, \ + rspamd_task_log_id, "task", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) @@ -221,8 +224,8 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); task->task_pool->tag.tagname, task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_task(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "task", task->task_pool->tag.uid, \ +#define msg_debug_task(...) rspamd_conditional_debug_fast (NULL, task->from_addr, \ + rspamd_task_log_id, "task", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) #define msg_err_task_encrypted(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL|RSPAMD_LOG_ENCRYPTED, \ @@ -237,10 +240,6 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); task->task_pool->tag.tagname, task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_task_encrypted(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG|RSPAMD_LOG_ENCRYPTED, \ - task->task_pool->tag.tagname, task->task_pool->tag.uid, \ - G_STRFUNC, \ - __VA_ARGS__) /* Check for NULL pointer first */ #define msg_err_task_check(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ @@ -254,8 +253,9 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_task_check(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ +#define msg_debug_task_check(...) rspamd_conditional_debug_fast (NULL, \ + task ? task->from_addr : NULL, \ + rspamd_task_log_id, "task", task ? task->task_pool->tag.uid : NULL, \ G_STRFUNC, \ __VA_ARGS__) @@ -272,7 +272,7 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); pool->tag.tagname, pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_pool(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ +#define msg_debug_pool(...) rspamd_conditional_debug (NULL, NULL, \ pool->tag.tagname, pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) @@ -285,12 +285,13 @@ ucl_object_t * rspamd_log_errorbuf_export (const rspamd_logger_t *logger); pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_info_pool_check(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \ +#define msg_info_pool_check(...) rspamd_conditional_debug (NULL, NULL, \ + G_LOG_LEVEL_INFO, \ pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_pool_check(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ +#define msg_debug_pool_check(...) rspamd_conditional_debug (NULL, NULL, \ pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ - G_STRFUNC, \ - __VA_ARGS__) + G_STRFUNC, \ + __VA_ARGS__) #endif diff --git a/src/libutil/map.c b/src/libutil/map.c index 01bafc82c..aeb7f9ed3 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -66,6 +66,12 @@ struct rspamd_http_map_cached_cbdata { time_t last_checked; }; +guint rspamd_map_log_id = (guint)-1; +RSPAMD_CONSTRUCTOR(rspamd_map_log_init) +{ + rspamd_map_log_id = rspamd_logger_add_debug_module("map"); +} + /** * Write HTTP request */ diff --git a/src/libutil/map_private.h b/src/libutil/map_private.h index fd2098cd1..1de6fb942 100644 --- a/src/libutil/map_private.h +++ b/src/libutil/map_private.h @@ -24,7 +24,7 @@ #include "ref.h" typedef void (*rspamd_map_dtor) (gpointer p); - +extern guint rspamd_map_log_id; #define msg_err_map(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ "map", map->tag, \ G_STRFUNC, \ @@ -37,8 +37,8 @@ typedef void (*rspamd_map_dtor) (gpointer p); "map", map->tag, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_map(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "map", map->tag, \ +#define msg_debug_map(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_map_log_id, "map", map->tag, \ G_STRFUNC, \ __VA_ARGS__) diff --git a/src/libutil/radix.c b/src/libutil/radix.c index bb295d7d1..8c2258459 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -31,11 +31,13 @@ "radix", tree->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_radix(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "radix", tree->pool->tag.uid, \ +#define msg_debug_radix(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_radix_log_id, "radix", tree->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(radix) + struct radix_tree_compressed { rspamd_mempool_t *pool; size_t size; |