diff --git a/ecmascript/compiler/BUILD.gn b/ecmascript/compiler/BUILD.gn index 4f337a1dfb..2b50384a96 100644 --- a/ecmascript/compiler/BUILD.gn +++ b/ecmascript/compiler/BUILD.gn @@ -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) { diff --git a/ecmascript/log.cpp b/ecmascript/log.cpp index c0f59d4efa..7a5b3734af 100644 --- a/ecmascript/log.cpp +++ b/ecmascript/log.cpp @@ -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(level))) { + if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, static_cast(level))) { return static_cast(level); } } diff --git a/ecmascript/log.h b/ecmascript/log.h index 2bc7561109..d2032de325 100644 --- a/ecmascript/log.h +++ b/ecmascript/log.h @@ -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(); } }