diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-01-20 14:10:08 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-01-20 14:10:08 +0000 |
commit | e9b802f8c73dff121421128c94076475e0df3bda (patch) | |
tree | f9a274ef11cbc873e06d520c720cb450a1f4766c /src/libserver | |
parent | b9f51206b4568a2cf4243bfdc5d192c1804d0b8e (diff) | |
download | rspamd-e9b802f8c73dff121421128c94076475e0df3bda.tar.gz rspamd-e9b802f8c73dff121421128c94076475e0df3bda.zip |
[Project] Convert all C modules to fast debug infrastructure
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/cfg_file.h | 6 | ||||
-rw-r--r-- | src/libserver/cfg_utils.c | 6 | ||||
-rw-r--r-- | src/libserver/composites.c | 7 | ||||
-rw-r--r-- | src/libserver/dkim.c | 6 | ||||
-rw-r--r-- | src/libserver/events.c | 6 | ||||
-rw-r--r-- | src/libserver/fuzzy_backend_sqlite.c | 6 | ||||
-rw-r--r-- | src/libserver/html.c | 6 | ||||
-rw-r--r-- | src/libserver/milter.c | 6 | ||||
-rw-r--r-- | src/libserver/monitored.c | 6 | ||||
-rw-r--r-- | src/libserver/re_cache.c | 11 | ||||
-rw-r--r-- | src/libserver/redis_pool.c | 6 | ||||
-rw-r--r-- | src/libserver/spf.c | 5 | ||||
-rw-r--r-- | src/libserver/symbols_cache.c | 6 | ||||
-rw-r--r-- | src/libserver/worker_util.h | 4 |
14 files changed, 57 insertions, 30 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 5f04a39a7..cb433b6d5 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -663,9 +663,11 @@ gboolean rspamd_config_radix_from_ucl (struct rspamd_config *cfg, cfg->cfg_pool->tag.tagname, cfg->checksum, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_config(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - cfg->cfg_pool->tag.tagname, cfg->checksum, \ +extern guint rspamd_config_log_id; +#define msg_debug_config(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_config_log_id, "config", cfg->checksum, \ G_STRFUNC, \ __VA_ARGS__) + #endif /* ifdef CFG_FILE_H */ diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index a0acb53b9..e14495ded 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -56,6 +56,12 @@ static gchar * rspamd_ucl_read_cb (gchar * chunk, gboolean final); static void rspamd_ucl_fin_cb (struct map_cb_data *data); +guint rspamd_config_log_id = (guint)-1; +RSPAMD_CONSTRUCTOR(rspamd_config_log_init) +{ + rspamd_config_log_id = rspamd_logger_add_debug_module("config"); +} + gboolean rspamd_parse_bind_line (struct rspamd_config *cfg, struct rspamd_worker_conf *cf, diff --git a/src/libserver/composites.c b/src/libserver/composites.c index e824ef8d4..6b6776f47 100644 --- a/src/libserver/composites.c +++ b/src/libserver/composites.c @@ -33,11 +33,14 @@ "composites", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_composites(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "composites", task->task_pool->tag.uid, \ + +#define msg_debug_composites(...) rspamd_conditional_debug_fast (NULL, task->from_addr, \ + rspamd_composites_log_id, "composites", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(composites) + struct composites_data { struct rspamd_task *task; struct rspamd_composite *composite; diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index d3aa7c0bc..dcf440355 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -86,11 +86,13 @@ enum rspamd_dkim_key_type { "dkim", ctx->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_dkim(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "dkim", ctx->pool->tag.uid, \ +#define msg_debug_dkim(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_dkim_log_id, "dkim", ctx->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(dkim) + struct rspamd_dkim_common_ctx { rspamd_mempool_t *pool; guint64 sig_hash; diff --git a/src/libserver/events.c b/src/libserver/events.c index 4a7d5d634..baf108e38 100644 --- a/src/libserver/events.c +++ b/src/libserver/events.c @@ -37,11 +37,13 @@ "events", session->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_session(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "events", session->pool->tag.uid, \ +#define msg_debug_session(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_events_log_id, "events", session->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(events) + struct rspamd_watch_stack { event_watcher_t cb; gpointer ud; diff --git a/src/libserver/fuzzy_backend_sqlite.c b/src/libserver/fuzzy_backend_sqlite.c index 6efa103a4..90c0db70d 100644 --- a/src/libserver/fuzzy_backend_sqlite.c +++ b/src/libserver/fuzzy_backend_sqlite.c @@ -46,11 +46,13 @@ static const guint max_retries = 10; backend->pool->tag.tagname, backend->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_fuzzy_backend(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - backend->pool->tag.tagname, backend->pool->tag.uid, \ +#define msg_debug_fuzzy_backend(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_fuzzy_sqlite_log_id, backend->pool->tag.tagname, backend->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(fuzzy_sqlite) + static const char *create_tables_sql = "BEGIN;" "CREATE TABLE IF NOT EXISTS digests(" diff --git a/src/libserver/html.c b/src/libserver/html.c index 26318db43..c21871a93 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -37,11 +37,13 @@ struct html_tag_def { guint flags; }; -#define msg_debug_html(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "html", pool->tag.uid, \ +#define msg_debug_html(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_html_log_id, "html", pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(html) + #define TAG_DEF(id, name, flags) {(name), (id), (sizeof(name) - 1), (flags)} static struct html_tag_def tag_defs[] = { diff --git a/src/libserver/milter.c b/src/libserver/milter.c index 1b3e4de7e..511655e92 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -41,11 +41,13 @@ "milter", priv->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_milter(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "milter", priv->pool->tag.uid, \ +#define msg_debug_milter(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_milter_log_id, "milter", priv->pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(milter) + struct rspamd_milter_context { gchar *spam_header; void *sessions_cache; diff --git a/src/libserver/monitored.c b/src/libserver/monitored.c index 96e161e1a..bd350e16d 100644 --- a/src/libserver/monitored.c +++ b/src/libserver/monitored.c @@ -78,11 +78,13 @@ struct rspamd_monitored { "monitored", m->tag, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_mon(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "monitored", m->tag, \ +#define msg_debug_mon(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_monitored_log_id, "monitored", m->tag, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(monitored) + static inline void rspamd_monitored_propagate_error (struct rspamd_monitored *m, const gchar *error) diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index d0e17603d..e92421658 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -52,15 +52,18 @@ "re_cache", cache->hash, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_re_cache(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "re_cache", cache->hash, \ + +#define msg_debug_re_task(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_re_cache_log_id, "re_cache", task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_re_task(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "re_cache", task->task_pool->tag.uid, \ +#define msg_debug_re_cache(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_re_cache_log_id, "re_cache", cache->hash, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(re_cache) + #ifdef WITH_HYPERSCAN #define RSPAMD_HS_MAGIC_LEN (sizeof (rspamd_hs_magic)) static const guchar rspamd_hs_magic[] = {'r', 's', 'h', 's', 'r', 'e', '1', '1'}, diff --git a/src/libserver/redis_pool.c b/src/libserver/redis_pool.c index bbc734173..3d77aca1c 100644 --- a/src/libserver/redis_pool.c +++ b/src/libserver/redis_pool.c @@ -67,11 +67,13 @@ static const guint default_max_conns = 100; "redis_pool", conn->tag, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_rpool(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "redis_pool", conn->tag, \ +#define msg_debug_rpool(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_redis_pool_log_id, "redis_pool", conn->tag, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(redis_pool) + static inline guint64 rspamd_redis_pool_get_key (const gchar *db, const gchar *password, const char *ip, int port) diff --git a/src/libserver/spf.c b/src/libserver/spf.c index b0afe1d66..8a19e3094 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -98,11 +98,12 @@ struct spf_record { "spf", rec->task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_spf(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - "spf", rec->task->task_pool->tag.uid, \ +#define msg_debug_spf(...) rspamd_conditional_debug_fast (NULL, rec->task->from_addr, \ + rspamd_spf_log_id, "spf", rec->task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(spf) struct spf_dns_cb { struct spf_record *rec; diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 5307c44b6..b890578ed 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -37,11 +37,13 @@ cache->static_pool->tag.tagname, cache->cfg->checksum, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_cache(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - cache->static_pool->tag.tagname, cache->cfg->checksum, \ +#define msg_debug_cache(...) rspamd_conditional_debug_fast (NULL, NULL, \ + rspamd_symcache_log_id, "symcache", cache->cfg->checksum, \ G_STRFUNC, \ __VA_ARGS__) +INIT_LOG_MODULE(symcache) + static const guchar rspamd_symbols_cache_magic[8] = {'r', 's', 'c', 2, 0, 0, 0, 0 }; static gint rspamd_symbols_cache_find_symbol_parent (struct symbols_cache *cache, diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h index 9e99a99a5..14ca3ff2a 100644 --- a/src/libserver/worker_util.h +++ b/src/libserver/worker_util.h @@ -202,9 +202,5 @@ void rspamd_worker_init_monitored (struct rspamd_worker *worker, rspamd_main->server_pool->tag.tagname, rspamd_main->server_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) -#define msg_debug_main(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ - rspamd_main->server_pool->tag.tagname, rspamd_main->server_pool->tag.uid, \ - G_STRFUNC, \ - __VA_ARGS__) #endif /* WORKER_UTIL_H_ */ |