From a54886730604f8c89816f6c1bd96f2066ef2054e Mon Sep 17 00:00:00 2001 From: liujialiang Date: Tue, 17 May 2022 21:00:38 +0800 Subject: [PATCH] fixed d3df102 from https://gitee.com/jokerxd-liu/utils_native/pulls/86 deal with the problem of log 1.The level of log in string_ex is too high. We decide to change it to DEBUG. 2.The log for DEBUG should not be print out in a common mode. So we give it a macro to divide it from common mode. Signed-off-by: liujialiang Change-Id: Ib6d7c263a7601b3c1867dd427b7f0b7f8e2f7f9a --- base/src/string_ex.cpp | 18 +++++++++--------- base/src/utils_log.h | 4 ++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/base/src/string_ex.cpp b/base/src/string_ex.cpp index 65ce7d2..dc12736 100644 --- a/base/src/string_ex.cpp +++ b/base/src/string_ex.cpp @@ -111,7 +111,7 @@ bool StrToInt(const string& str, int& value) auto result = strtol(addr, &end, 10); /* 10 means decimal */ if ((end == addr) || (end[0] != '\0') || (errno == ERANGE) || (result > INT_MAX) || (result < INT_MIN)) { - UTILS_LOGE("call StrToInt func false, input str is: %{public}s!", str.c_str()); + UTILS_LOGD("call StrToInt func false, input str is: %{public}s!", str.c_str()); return false; } @@ -122,13 +122,13 @@ bool StrToInt(const string& str, int& value) bool IsNumericStr(const string& str) { if (str.empty()) { - UTILS_LOGE("call IsNumericStr func, input str is empty!"); + UTILS_LOGD("call IsNumericStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!isdigit(c)) { - UTILS_LOGE("call IsNumericStr func false, input str is: %{public}s!", str.c_str()); + UTILS_LOGD("call IsNumericStr func false, input str is: %{public}s!", str.c_str()); return false; } } @@ -139,13 +139,13 @@ bool IsNumericStr(const string& str) bool IsAlphaStr(const string& str) { if (str.empty()) { - UTILS_LOGE("call IsAlphaStr func, input str is empty!"); + UTILS_LOGD("call IsAlphaStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!isalpha(c)) { - UTILS_LOGE("call IsAlphaStr func false, input str is: %{public}s!", str.c_str()); + UTILS_LOGD("call IsAlphaStr func false, input str is: %{public}s!", str.c_str()); return false; } } @@ -156,13 +156,13 @@ bool IsAlphaStr(const string& str) bool IsUpperStr(const string& str) { if (str.empty()) { - UTILS_LOGE("call IsUpperStr func, input str is empty!"); + UTILS_LOGD("call IsUpperStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!isupper(c)) { - UTILS_LOGE("call IsUpperStr func false, input str is: %{public}s!", str.c_str()); + UTILS_LOGD("call IsUpperStr func false, input str is: %{public}s!", str.c_str()); return false; } } @@ -173,13 +173,13 @@ bool IsUpperStr(const string& str) bool IsLowerStr(const string& str) { if (str.empty()) { - UTILS_LOGE("call IsLowerStr func, input str is empty!"); + UTILS_LOGD("call IsLowerStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!islower(c)) { - UTILS_LOGE("call IsLowerStr func false, input str is: %{public}s!", str.c_str()); + UTILS_LOGD("call IsLowerStr func false, input str is: %{public}s!", str.c_str()); return false; } } diff --git a/base/src/utils_log.h b/base/src/utils_log.h index 9fda24f..1b3efac 100644 --- a/base/src/utils_log.h +++ b/base/src/utils_log.h @@ -24,8 +24,12 @@ constexpr const char *UTILS_LOG_TAG = "utils_base"; #define UTILS_LOGE(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_ERROR, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) #define UTILS_LOGW(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_WARN, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) #define UTILS_LOGI(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_INFO, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) +#ifdef DEBUG_UTILS #define UTILS_LOGD(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_DEBUG, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) #else +#define UTILS_LOGD(...) +#endif +#else #define UTILS_LOGF(...) #define UTILS_LOGE(...) #define UTILS_LOGW(...) -- Gitee