]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Improve logging in lambdas
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 14 May 2022 11:07:03 +0000 (12:07 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 14 May 2022 11:07:03 +0000 (12:07 +0100)
src/libserver/logger.h
src/libserver/symcache/symcache_internal.hxx
src/libserver/symcache/symcache_runtime.cxx

index ae3ea469495b8c2e0582d7d8dca5da17d84f4357..35792e68eb5bcf6d6e1b32294b33c1587592a131 100644 (file)
@@ -290,6 +290,10 @@ extern guint rspamd_task_log_id;
         task->task_pool->tag.tagname, task->task_pool->tag.uid, \
         RSPAMD_LOG_FUNC, \
         __VA_ARGS__)
+#define msg_err_task_lambda(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
+        task->task_pool->tag.tagname, task->task_pool->tag.uid, \
+        log_func, \
+        __VA_ARGS__)
 #define msg_warn_task(...)   rspamd_default_log_function (G_LOG_LEVEL_WARNING, \
         task->task_pool->tag.tagname, task->task_pool->tag.uid, \
         RSPAMD_LOG_FUNC, \
@@ -310,6 +314,10 @@ extern guint rspamd_task_log_id;
         rspamd_task_log_id, "task", task->task_pool->tag.uid, \
         RSPAMD_LOG_FUNC, \
         __VA_ARGS__)
+#define msg_debug_task_lambda(...)  rspamd_conditional_debug_fast (NULL,  task->from_addr, \
+        rspamd_task_log_id, "task", task->task_pool->tag.uid, \
+        log_func, \
+        __VA_ARGS__)
 #define msg_err_task_encrypted(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL|RSPAMD_LOG_ENCRYPTED, \
         task->task_pool->tag.tagname, task->task_pool->tag.uid, \
         RSPAMD_LOG_FUNC, \
index 00c0d4d8b4f70a9dc8583a0e5fc49bfb3351d254..84ae8de7f05271ebccbc5af87dc8fa5a77f06584 100644 (file)
         ::rspamd::symcache::rspamd_symcache_log_id, "symcache", task->task_pool->tag.uid, \
         RSPAMD_LOG_FUNC, \
         __VA_ARGS__)
+#define msg_debug_cache_task_lambda(...)  rspamd_conditional_debug_fast (NULL, NULL, \
+        ::rspamd::symcache::rspamd_symcache_log_id, "symcache", task->task_pool->tag.uid, \
+        log_func, \
+        __VA_ARGS__)
 
 struct lua_State;
 
index 788a36ec9cdbd20956d18e354177996ad387b142..1bcebbdc76534579d077d1f644cd5741830f0753 100644 (file)
@@ -532,10 +532,11 @@ auto symcache_runtime::check_item_deps(struct rspamd_task *task, symcache &cache
                                                                           cache_dynamic_item *dyn_item, bool check_only) -> bool
 {
        constexpr const auto max_recursion = 20;
+       auto log_func = RSPAMD_LOG_FUNC;
 
        auto inner_functor = [&](int recursion, cache_item *item, cache_dynamic_item *dyn_item, auto rec_functor) -> bool {
                if (recursion > max_recursion) {
-                       msg_err_task ("cyclic dependencies: maximum check level %ud exceed when "
+                       msg_err_task_lambda("cyclic dependencies: maximum check level %ud exceed when "
                                                  "checking dependencies for %s", max_recursion, item->symbol.c_str());
 
                        return true;
@@ -546,7 +547,7 @@ auto symcache_runtime::check_item_deps(struct rspamd_task *task, symcache &cache
                for (const auto &dep: item->deps) {
                        if (!dep.item) {
                                /* Assume invalid deps as done */
-                               msg_debug_cache_task("symbol %d(%s) has invalid dependencies on %d(%s)",
+                               msg_debug_cache_task_lambda("symbol %d(%s) has invalid dependencies on %d(%s)",
                                                item->id, item->symbol.c_str(), dep.id, dep.sym.c_str());
                                continue;
                        }
@@ -563,26 +564,26 @@ auto symcache_runtime::check_item_deps(struct rspamd_task *task, symcache &cache
                                                                rec_functor)) {
 
                                                        ret = false;
-                                                       msg_debug_cache_task("delayed dependency %d(%s) for "
+                                                       msg_debug_cache_task_lambda("delayed dependency %d(%s) for "
                                                                                                 "symbol %d(%s)",
                                                                        dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                                }
                                                else if (!process_symbol(task, cache, dep.item.get(), dep_dyn_item)) {
                                                        /* Now started, but has events pending */
                                                        ret = false;
-                                                       msg_debug_cache_task("started check of %d(%s) symbol "
+                                                       msg_debug_cache_task_lambda("started check of %d(%s) symbol "
                                                                                                 "as dep for "
                                                                                                 "%d(%s)",
                                                                        dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                                }
                                                else {
-                                                       msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is "
+                                                       msg_debug_cache_task_lambda("dependency %d(%s) for symbol %d(%s) is "
                                                                                                 "already processed",
                                                                        dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                                }
                                        }
                                        else {
-                                               msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) "
+                                               msg_debug_cache_task_lambda("dependency %d(%s) for symbol %d(%s) "
                                                                                         "cannot be started now",
                                                                dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                                ret = false;
@@ -590,14 +591,14 @@ auto symcache_runtime::check_item_deps(struct rspamd_task *task, symcache &cache
                                }
                                else {
                                        /* Started but not finished */
-                                       msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is "
+                                       msg_debug_cache_task_lambda("dependency %d(%s) for symbol %d(%s) is "
                                                                                 "still executing",
                                                        dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                        ret = false;
                                }
                        }
                        else {
-                               msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is already "
+                               msg_debug_cache_task_lambda("dependency %d(%s) for symbol %d(%s) is already "
                                                                         "checked",
                                                dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                        }