diff --git a/frameworks/i18n/BUILD.gn b/frameworks/i18n/BUILD.gn index 82d2cf045fbc1dfb71e9d8f5af1dc64462d1cb4c..56a13938ddc25af38718dc3efa4848df4e62b554 100644 --- a/frameworks/i18n/BUILD.gn +++ b/frameworks/i18n/BUILD.gn @@ -61,7 +61,10 @@ if (defined(ohos_lite)) { if (i18n_lite_support_i18n_product) { include_dirs = [ "//commonlibrary/utils_lite/memory/include" ] defines = [ "I18N_PRODUCT" ] - deps += [ "//commonlibrary/utils_lite:utils" ] + deps += [ + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//commonlibrary/utils_lite:utils", + ] } } } else { diff --git a/frameworks/i18n/include/i18n_hilog_lite.h b/frameworks/i18n/include/i18n_hilog_lite.h new file mode 100644 index 0000000000000000000000000000000000000000..cfe8d562219cc8ddfb375f238702965c43be5f37 --- /dev/null +++ b/frameworks/i18n/include/i18n_hilog_lite.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_GLOBAL_I18N_LITE_HILOG +#define OHOS_GLOBAL_I18N_LITE_HILOG + +#ifdef I18N_PRODUCT +#include "hilog/log.h" + +#ifdef HILOG_ERROR +#undef HILOG_ERROR +#endif + +static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, 0, "GlobalI18nLite"}; +#define HILOG_ERROR(...) (void)OHOS::HiviewDFX::HiLog::Error(LOG_LABEL, __VA_ARGS__) +#endif +#endif \ No newline at end of file diff --git a/frameworks/i18n/src/data_resource.cpp b/frameworks/i18n/src/data_resource.cpp index 1732c1c9405a3184c5252a87aaf586cad2104b45..53e5d9aedece17a84506016779339914e14bdf5c 100644 --- a/frameworks/i18n/src/data_resource.cpp +++ b/frameworks/i18n/src/data_resource.cpp @@ -15,6 +15,10 @@ #include "data_resource.h" #include +#ifdef I18N_PRODUCT +#include +#include "i18n_hilog_lite.h" +#endif #include "i18n_memory_adapter.h" #include "securec.h" #include "str_util.h" @@ -147,6 +151,9 @@ bool DataResource::Init(void) { int32_t infile = open(DATA_RESOURCE_PATH, O_RDONLY); if (infile < 0) { +#ifdef I18N_PRODUCT + HILOG_ERROR("DataResource::Init: open DATA_RESOURCE_PATH failed, errno is %{public}d.", errno); +#endif return false; } bool ret = ReadHeader(infile);