商用版本日志打印去除文件名和行号

Signed-off-by: zoulinken <zoulinken1@huawei.com>
This commit is contained in:
zoulinken 2024-08-29 14:45:34 +08:00
parent 1573c089e5
commit 47881c003d
5 changed files with 25 additions and 1 deletions

View File

@ -185,6 +185,10 @@ if (enable_dump_drawcmd) {
ace_common_defines += [ "DUMP_DRAW_CMD" ]
}
if (build_variant == "user") {
ace_common_defines += [ "IS_RELEASE_VERSION" ]
}
ace_use_new_skia = true
ace_use_rosen_drawing = false

View File

@ -24,9 +24,14 @@
#define UISERVICE_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
#define ACE_FMT_PREFIX "[%{public}s:%{public}d]"
#ifdef IS_RELEASE_VERSION
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, fmt, ##__VA_ARGS__)
#else
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, ACE_FMT_PREFIX fmt, UISERVICE_FILENAME, \
__LINE__, ##__VA_ARGS__)
#endif
#define LOGE(fmt, ...) PRINT_LOG(ERROR, fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) PRINT_LOG(WARN, fmt, ##__VA_ARGS__)

View File

@ -24,9 +24,14 @@
#define UISERVICE_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
#define ACE_FMT_PREFIX "[%{public}s:%{public}d]"
#ifdef IS_RELEASE_VERSION
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, fmt, ##__VA_ARGS__)
#else
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, \
ACE_FMT_PREFIX fmt, UISERVICE_FILENAME, __LINE__, ##__VA_ARGS__)
#endif
#define LOGE(fmt, ...) PRINT_LOG(ERROR, fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) PRINT_LOG(WARN, fmt, ##__VA_ARGS__)

View File

@ -37,11 +37,16 @@
#include "hilog/log.h"
constexpr uint32_t ACE_DOMAIN = 0xD003900;
constexpr uint32_t APP_DOMAIN = 0xC0D0;
#ifdef IS_RELEASE_VERSION
#define PRINT_LOG(level, tag, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, (tag + ACE_DOMAIN), (OHOS::Ace::g_DOMAIN_CONTENTS_MAP.at(tag)), \
"[(%{public}s)] " fmt, OHOS::Ace::LogWrapper::GetIdWithReason().c_str(), ##__VA_ARGS__)
#else
#define PRINT_LOG(level, tag, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, (tag + ACE_DOMAIN), (OHOS::Ace::g_DOMAIN_CONTENTS_MAP.at(tag)), \
ACE_FMT_PREFIX fmt, OHOS::Ace::LogWrapper::GetBriefFileName(__FILE__), \
__LINE__ ACE_LOG_ID_WITH_REASON, ##__VA_ARGS__)
#endif
#define PRINT_APP_LOG(level, fmt, ...) HILOG_IMPL(LOG_APP, LOG_##level, APP_DOMAIN, "JSAPP", fmt, ##__VA_ARGS__)
#else
#define PRINT_LOG(level, tag, fmt, ...) \

View File

@ -55,9 +55,14 @@
static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, FR_LOG_DOMAIN, FR_LOG_TAG};
#define FR_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
#ifdef IS_RELEASE_VERSION
#define PRINT_HILOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, FR_LOG_DOMAIN, FR_LOG_TAG, fmt, ##__VA_ARGS__)
#else
#define PRINT_HILOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, FR_LOG_DOMAIN, FR_LOG_TAG, "[%{public}s:%{public}d]" fmt, \
FR_FILENAME, __LINE__, ##__VA_ARGS__)
#endif
#define HILOG_FATAL(fmt, ...) PRINT_HILOG(FATAL, fmt, ##__VA_ARGS__)
#define HILOG_ERROR(fmt, ...) PRINT_HILOG(ERROR, fmt, ##__VA_ARGS__)