From 0614ffac9474c70429f85338d702c82ca7789a4e Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 13 Mar 2024 16:46:33 +0800 Subject: [PATCH 1/2] Resolve the issue of call_log_enter not printing Signed-off-by: cff-gite Change-Id: I74611806fd5c327422b13115bd988ab71d1a6682 --- utils/common/include/sensor_errors.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/utils/common/include/sensor_errors.h b/utils/common/include/sensor_errors.h index cb181d28..f00d4e6e 100644 --- a/utils/common/include/sensor_errors.h +++ b/utils/common/include/sensor_errors.h @@ -126,20 +126,29 @@ enum { class InnerFunctionTracer { public: - InnerFunctionTracer(const char *func) - : func_ { func } + InnerFunctionTracer(const char *func, const char *tag) + : func_ { func }, tag_ { tag } { - HILOG_DEBUG(LOG_CORE, "in %{public}s, enter", func_); + if (HiLogIsLoggable(LOG_DOMAIN, tag_, LOG_DEBUG)) { + if (func_ != nullptr && tag_ != nullptr) { + HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, tag_, "in %{public}s, enter", func_ ); + } + } } ~InnerFunctionTracer() { - HILOG_DEBUG(LOG_CORE, "in %{public}s, leave", func_); + if (HiLogIsLoggable(LOG_DOMAIN, tag_, LOG_DEBUG)) { + if (func_ != nullptr && tag_ != nullptr) { + HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, tag_, "in %{public}s, leave", func_ ); + } + } } private: const char *func_ { nullptr }; + const char *tag_ { nullptr }; }; -#define CALL_LOG_ENTER InnerFunctionTracer ___innerFuncTracer___ { __FUNCTION__ } +#define CALL_LOG_ENTER InnerFunctionTracer ___innerFuncTracer___ { __FUNCTION__, LOG_TAG } #ifdef DEBUG_CODE_TEST #define CHKPL(cond, ...) \ -- Gitee From 52df0c741f0308cbd4d6b149d12cbc698d0121a5 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 13 Mar 2024 20:03:54 +0800 Subject: [PATCH 2/2] Resolve the issue of call_log_enter not printing Signed-off-by: cff-gite Change-Id: I79335f040f63a7e614f13eb997bf3d19b8702bcd --- utils/common/include/sensor_errors.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/common/include/sensor_errors.h b/utils/common/include/sensor_errors.h index f00d4e6e..df4aab82 100644 --- a/utils/common/include/sensor_errors.h +++ b/utils/common/include/sensor_errors.h @@ -127,11 +127,11 @@ enum { class InnerFunctionTracer { public: InnerFunctionTracer(const char *func, const char *tag) - : func_ { func }, tag_ { tag } + : func_ { func }, tag_ { tag } { if (HiLogIsLoggable(LOG_DOMAIN, tag_, LOG_DEBUG)) { if (func_ != nullptr && tag_ != nullptr) { - HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, tag_, "in %{public}s, enter", func_ ); + HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, tag_, "in %{public}s, enter", func_); } } } @@ -139,7 +139,7 @@ public: { if (HiLogIsLoggable(LOG_DOMAIN, tag_, LOG_DEBUG)) { if (func_ != nullptr && tag_ != nullptr) { - HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, tag_, "in %{public}s, leave", func_ ); + HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, tag_, "in %{public}s, leave", func_); } } } -- Gitee