Change hilog to light hilog

Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8WLU6?from=project-issue

Signed-off-by: yaochaonan <yaochaonan@huawei.com>
Change-Id: Iba4517e2dc4fd857ef5eb8530b4d6b41af58187d
This commit is contained in:
yaochaonan 2024-03-26 10:55:28 +08:00
parent c04d25cdcd
commit f80a725785
3 changed files with 22 additions and 10 deletions

View File

@ -430,6 +430,11 @@ ohos_shared_library("libark_jsoptimizer") {
defines = [ "RUN_WITH_ASAN" ]
}
external_deps = []
if (enable_hilog) {
external_deps += [ "hilog:libhilog" ]
}
install_enable = false
if (!is_mingw && !is_mac) {

View File

@ -54,7 +54,7 @@ Level ConvertToLevel(LogLevel hilogLevel)
LogLevel GetHiLogLevel()
{
for (int32_t level = LogLevel::LOG_LEVEL_MIN; level <= LogLevel::LOG_LEVEL_MAX; level++) {
if (HiLogIsLoggable(ARK_DOMAIN, TAG, static_cast<LogLevel>(level))) {
if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, static_cast<LogLevel>(level))) {
return static_cast<LogLevel>(level);
}
}

View File

@ -24,8 +24,18 @@
#include "ecmascript/napi/include/jsnapi.h"
#ifdef ENABLE_HILOG
#include "hilog/log.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif
#include "hilog/log.h"
#undef LOG_DOMAIN
#define LOG_DOMAIN 0xD003F00
#undef LOG_TAG
#define LOG_TAG "ArkCompiler"
#endif
using LOG_LEVEL = panda::RuntimeOption::LOG_LEVEL;
enum Level {
@ -54,9 +64,6 @@ enum Component {
namespace panda::ecmascript {
#ifdef ENABLE_HILOG
constexpr static unsigned int ARK_DOMAIN = 0xD003F00;
constexpr static auto TAG = "ArkCompiler";
constexpr static OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, ARK_DOMAIN, TAG};
#if ECMASCRIPT_ENABLE_VERBOSE_LEVEL_LOG
// print Debug level log if enable Verbose log
@ -128,15 +135,15 @@ public:
if constexpr (level == LOG_LEVEL_MIN) {
// print nothing
} else if constexpr (level == LOG_DEBUG) {
OHOS::HiviewDFX::HiLog::Debug(LABEL, "%{public}s", stream_.str().c_str());
HILOG_DEBUG(LOG_CORE, "%{public}s", stream_.str().c_str());
} else if constexpr (level == LOG_INFO) {
OHOS::HiviewDFX::HiLog::Info(LABEL, "%{public}s", stream_.str().c_str());
HILOG_INFO(LOG_CORE, "%{public}s", stream_.str().c_str());
} else if constexpr (level == LOG_WARN) {
OHOS::HiviewDFX::HiLog::Warn(LABEL, "%{public}s", stream_.str().c_str());
HILOG_WARN(LOG_CORE, "%{public}s", stream_.str().c_str());
} else if constexpr (level == LOG_ERROR) {
OHOS::HiviewDFX::HiLog::Error(LABEL, "%{public}s", stream_.str().c_str());
HILOG_ERROR(LOG_CORE, "%{public}s", stream_.str().c_str());
} else {
OHOS::HiviewDFX::HiLog::Fatal(LABEL, "%{public}s", stream_.str().c_str());
HILOG_FATAL(LOG_CORE, "%{public}s", stream_.str().c_str());
std::abort();
}
}