From 68754d676f6962221074bbcc53855611e846f606 Mon Sep 17 00:00:00 2001 From: buzhenwang Date: Thu, 26 Dec 2024 19:33:23 +0800 Subject: [PATCH] adapt setMinLogLevel for platform Signed-off-by: buzhenwang --- platform/hilog_printf.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/hilog_printf.cpp b/platform/hilog_printf.cpp index d5652f3..9eced91 100644 --- a/platform/hilog_printf.cpp +++ b/platform/hilog_printf.cpp @@ -16,6 +16,8 @@ #include "hilog/log.h" #include "interface/native/log.h" +static int g_logLevel = LOG_LEVEL_MIN; + static OHOS::Ace::LogLevel ConvertLogLevel(LogLevel level) { switch (level) { @@ -51,9 +53,14 @@ int HiLogPrint(LogType type, LogLevel level, unsigned int domain, const char *ta return ret; } +void HiLogSetAppMinLogLevel(LogLevel level) +{ + g_logLevel = level; +} + bool HiLogIsLoggable(unsigned int domain, const char *tag, LogLevel level) { - if ((level <= LOG_LEVEL_MIN) || (level >= LOG_LEVEL_MAX) || tag == nullptr) { + if ((level <= LOG_LEVEL_MIN) || (level >= LOG_LEVEL_MAX) || (level < g_logLevel) || tag == nullptr) { return false; } -- Gitee