From 67f20f2801c5c35aa4400ea06a4c9393023c3418 Mon Sep 17 00:00:00 2001 From: ganlan Date: Wed, 21 Sep 2022 01:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=B3=BB=E7=BB=9F=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E8=BF=9B=E8=A1=8Clinker=20log=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganlan --- BUILD.gn | 6 + musl_config.gni | 4 +- musl_src.gni | 2 + musl_template.gni | 11 +- porting/linux/user/etc/musl.para | 31 +++++ porting/linux/user/ldso/dynlink.c | 52 +++++++- porting/linux/user/ldso/ld_log.c | 122 ++++++++++++++++++ porting/linux/user/ldso/ld_log.h | 37 ++++-- porting/linux/user/src/hilog/hilog_adapter.c | 57 +++++++- .../linux/user/src/internal/hilog_adapter.h | 4 + porting/linux/user/src/internal/musl_log.h | 2 +- 11 files changed, 303 insertions(+), 25 deletions(-) create mode 100644 porting/linux/user/etc/musl.para create mode 100644 porting/linux/user/ldso/ld_log.c diff --git a/BUILD.gn b/BUILD.gn index e558af49..acfa3b79 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -47,10 +47,16 @@ if (is_lite_system && current_os == "ohos") { group("musl_libs") { deps = [ ":musl_headers", + ":musl_sysparam", ":soft_libs", ] } + ohos_prebuilt_etc("musl_sysparam") { + source = "${musl_porting_dir}/etc/musl.para" + relative_install_dir = "param" + } + musl_libs("soft_libs") { } diff --git a/musl_config.gni b/musl_config.gni index f00a407d..bfc1d9a2 100644 --- a/musl_config.gni +++ b/musl_config.gni @@ -53,7 +53,9 @@ declare_args() { } declare_args() { - enable_musl_log = false + if (!is_standard_system) { + enable_musl_log = false + } musl_secure_level = 1 } diff --git a/musl_src.gni b/musl_src.gni index e8e5fe29..d0717cec 100644 --- a/musl_src.gni +++ b/musl_src.gni @@ -1668,6 +1668,7 @@ musl_src_ldso = [ "ldso/ns_config.c", "ldso/strops.c", "ldso/dynlink_rand.c", + "ldso/ld_log.c", ] if (musl_arch == "arm") { @@ -2095,6 +2096,7 @@ musl_src_porting_file = [ "crt/arm/crti.s", "crt/aarch64/crti.s", "ldso/ld_log.h", + "ldso/ld_log.c", "ldso/namespace.c", "ldso/ns_config.c", "ldso/strops.c", diff --git a/musl_template.gni b/musl_template.gni index e71324d3..069b7917 100644 --- a/musl_template.gni +++ b/musl_template.gni @@ -149,8 +149,10 @@ template("musl_libs") { ] } - if (enable_musl_log) { - defines += [ "ENABLE_MUSL_LOG" ] + if (!is_standard_system && defined(enable_musl_log)) { + if (enable_musl_log) { + defines += [ "ENABLE_MUSL_LOG" ] + } } dynamic_list = @@ -366,6 +368,11 @@ template("musl_libs") { } deps = porting_deps + + if (is_standard_system) { + defines += [ "OHOS_ENABLE_PARAMETER" ] + deps += [ "//base/startup/init/services/param/base:parameterbase" ] + } } source_set("soft_musl_src_nossp") { diff --git a/porting/linux/user/etc/musl.para b/porting/linux/user/etc/musl.para new file mode 100644 index 00000000..d95e23a4 --- /dev/null +++ b/porting/linux/user/etc/musl.para @@ -0,0 +1,31 @@ +# Copyright (c) 2022 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. + +musl.log.enable=false + +# ================================ +# sample: +# +# * enable ld log for all apps +# musl.log.ld.all=true +# +# * enable ld log for specified app +# musl.log.ld.all=false +# musl.log.ld.app.your_app_name=true +# +# * enable ld log for apps excluding the specified app +# musl.log.ld.all=true +# musl.log.ld.app.your_app_name=false +# ================================ + +musl.log.ld.all=true \ No newline at end of file diff --git a/porting/linux/user/ldso/dynlink.c b/porting/linux/user/ldso/dynlink.c index 07572a3f..33a62e4f 100644 --- a/porting/linux/user/ldso/dynlink.c +++ b/porting/linux/user/ldso/dynlink.c @@ -483,7 +483,11 @@ static int check_vna_hash(Verdef *def, int16_t vsym, uint32_t vna_hash) } verdef = (Verdef *)((char *)verdef + verdef->vd_next); } - +#if (LD_LOG_LEVEL & LD_LOG_DEBUG) + if (!matched) { + LD_LOGD("check_vna_hash no matched found. vsym=%{public}d vna_hash=%{public}x", vsym, vna_hash); + } +#endif return matched; } @@ -494,6 +498,8 @@ static int check_verinfo(Verdef *def, int16_t *versym, uint32_t index, struct ve if (strlen(verinfo->v) == 0) { return 1; } else { + LD_LOGD("check_verinfo versym or def is null and verinfo->v exist, s:%{public}s v:%{public}s.", + verinfo->s, verinfo->v); return 0; } } @@ -512,6 +518,7 @@ static int check_verinfo(Verdef *def, int16_t *versym, uint32_t index, struct ve if (vsym >= 0) { return 1; } else { + LD_LOGD("check_verinfo not default version. vsym:%{public}d s:%{public}s", vsym, verinfo->s); return 0; } } @@ -530,7 +537,14 @@ static int check_verinfo(Verdef *def, int16_t *versym, uint32_t index, struct ve Verdaux *aux = (Verdaux *)((char *)def + def->vd_aux); - return !strcmp(verinfo->v, strings + aux->vda_name); + int ret = !strcmp(verinfo->v, strings + aux->vda_name); +#if (LD_LOG_LEVEL & LD_LOG_DEBUG) + if (!ret) { + LD_LOGD("check_verinfo version not match. s=%{public}s v=%{public}s vsym=%{public}d vda_name=%{public}s", + verinfo->s, verinfo->v, vsym, strings + aux->vda_name); + } +#endif + return ret; } static uint32_t sysv_hash(const char *s0) @@ -570,6 +584,9 @@ static Sym *sysv_lookup(struct verinfo *verinfo, uint32_t h, struct dso *dso) } } + LD_LOGD("sysv_lookup not find the symbol, " + "so:%{public}s s:%{public}s v:%{public}s use_vna_hash:%{public}d vna_hash:%{public}x", + dso->name, verinfo->s, verinfo->v, verinfo->use_vna_hash, verinfo->vna_hash); return 0; } @@ -579,7 +596,10 @@ static Sym *gnu_lookup(uint32_t h1, uint32_t *hashtab, struct dso *dso, struct v uint32_t *buckets = hashtab + 4 + hashtab[2]*(sizeof(size_t)/4); uint32_t i = buckets[h1 % nbuckets]; - if (!i) return 0; + if (!i) { + LD_LOGD("gnu_lookup symbol not found (bloom filter), so:%{public}s s:%{public}s", dso->name, verinfo->s); + return 0; + } uint32_t *hashval = buckets + nbuckets + (i - hashtab[1]); @@ -597,6 +617,9 @@ static Sym *gnu_lookup(uint32_t h1, uint32_t *hashtab, struct dso *dso, struct v if (h2 & 1) break; } + LD_LOGD("gnu_lookup symbol not found, " + "so:%{public}s s:%{public}s v:%{public}s use_vna_hash:%{public}d vna_hash:%{public}x", + dso->name, verinfo->s, verinfo->v, verinfo->use_vna_hash, verinfo->vna_hash); return 0; } @@ -616,6 +639,7 @@ static Sym *gnu_lookup_filtered(uint32_t h1, uint32_t *hashtab, struct dso *dso, static bool check_sym_accessible(struct dso *dso, ns_t *ns) { if (!dso || !dso->namespace || !ns) { + LD_LOGD("check_sym_accessible invalid parameter!"); return false; } if (dso->namespace == ns) { @@ -626,6 +650,8 @@ static bool check_sym_accessible(struct dso *dso, ns_t *ns) return true; } } + LD_LOGD( + "check_sym_accessible dso name [%{public}s] ns_name [%{public}s] not accessible!", dso->name, ns->ns_name); return false; } @@ -840,6 +866,9 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri dso->lazy_cnt++; continue; } + LD_LOGE("relocating failed: symbol not found. " + "dso=%{public}s s=%{public}s use_vna_hash=%{public}d van_hash=%{public}x", + dso->name, name, vinfo.use_vna_hash, vinfo.vna_hash); error("Error relocating %s: %s: symbol not found", dso->name, name); if (runtime) longjmp(*rtld_fail, 1); @@ -2309,6 +2338,8 @@ void __dls3(size_t *sp, size_t *auxv) #ifdef OHOS_ENABLE_PARAMETER InitParameterClient(); #endif + musl_log_reset(); + ld_log_reset(); /* If the main program was already loaded by the kernel, * AT_PHDR will point to some location other than the dynamic * linker's program headers. */ @@ -2860,6 +2891,8 @@ end: void *dlopen(const char *file, int mode) { const void *caller_addr = __builtin_return_address(0); + musl_log_reset(); + ld_log_reset(); LD_LOGI("dlopen file:%{public}s, mode:%{public}x ,caller_addr:%{public}p .", file, mode, caller_addr); return dlopen_impl(file, mode, NULL, caller_addr, NULL); } @@ -2912,11 +2945,13 @@ int dlns_get(const char *name, Dl_namespace *dlns) void *dlopen_ns(Dl_namespace *dlns, const char *file, int mode) { const void *caller_addr = __builtin_return_address(0); + musl_log_reset(); + ld_log_reset(); LD_LOGI("dlopen_ns file:%{public}s, mode:%{public}x , caller_addr:%{public}p , dlns->name:%{public}s.", file, mode, caller_addr, - dlns->name); + dlns ? dlns->name : "NULL"); return dlopen_impl(file, mode, dlns->name, caller_addr, NULL); } @@ -3082,6 +3117,7 @@ static void *do_dlsym(struct dso *p, const char *s, const char *v, void *ra) struct verinfo verinfo = { .s = s, .v = v, .use_vna_hash = false }; struct symdef def = find_sym2(p, &verinfo, 0, use_deps, ns); if (!def.sym) { + LD_LOGE("do_dlsym failed: symbol not found. so=%{public}s s=%{public}s v=%{public}s", p->name, s, v); error("Symbol not found: %s, version: %s", s, strlen(v) > 0 ? v : "null"); return 0; } @@ -3300,6 +3336,8 @@ int dladdr(const void *addr_arg, Dl_info *info) hidden void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra) { void *res; + musl_log_reset(); + ld_log_reset(); pthread_rwlock_rdlock(&lock); #ifdef HANDLE_RANDOMIZATION if ((p != RTLD_DEFAULT) && (p != RTLD_NEXT)) { @@ -3322,6 +3360,8 @@ hidden void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra hidden void *__dlvsym(void *restrict p, const char *restrict s, const char *restrict v, void *restrict ra) { void *res; + musl_log_reset(); + ld_log_reset(); pthread_rwlock_rdlock(&lock); #ifdef HANDLE_RANDOMIZATION if ((p != RTLD_DEFAULT) && (p != RTLD_NEXT)) { @@ -3523,13 +3563,15 @@ int handle_asan_path_open(int fd, const char *name, ns_t *namespace, char *buf, void* dlopen_ext(const char *file, int mode, const dl_extinfo *extinfo) { + const void *caller_addr = __builtin_return_address(0); + musl_log_reset(); + ld_log_reset(); if (extinfo != NULL) { if ((extinfo->flag & ~(DL_EXT_VALID_FLAG_BITS)) != 0) { LD_LOGE("Error dlopen_ext %{public}s: invalid flag %{public}x", file, extinfo->flag); return NULL; } } - const void *caller_addr = __builtin_return_address(0); LD_LOGI("dlopen_ext file:%{public}s, mode:%{public}x , caller_addr:%{public}p , extinfo->flag:%{public}x", file, mode, diff --git a/porting/linux/user/ldso/ld_log.c b/porting/linux/user/ldso/ld_log.c new file mode 100644 index 00000000..0505d9bd --- /dev/null +++ b/porting/linux/user/ldso/ld_log.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2022 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. + */ + +#include "ld_log.h" + +static bool ld_log_enable = false; + +#ifdef OHOS_ENABLE_PARAMETER +#include +#include +#include +#include +#include + +#include "sys_param.h" + +#define SYSPARAM_LENGTH 32 +#define PROCESS_NAME_LEN 1024 + +static char *get_app_name(char *buf, size_t length) +{ + char *app = NULL; + int fd = open("/proc/self/cmdline", O_RDONLY); + if (fd != -1) { + ssize_t ret = read(fd, buf, length - 1); + if (ret != -1) { + buf[ret] = 0; + app = strrchr(buf, '/'); + if (app) { + app++; + } else { + app = buf; + } + char *app_end = strchr(app, ':'); + if (app_end) { + *app_end = 0; + } + } + close(fd); + } + return app; +} + +static bool get_ld_log_app_value(char *buffer, uint32_t *length) +{ + char buf[PROCESS_NAME_LEN]; + char *path = get_app_name(buf, PROCESS_NAME_LEN); + if (!path) { + buffer[0] = 0; + return false; + } + + char app_param_name[PROCESS_NAME_LEN] = "musl.log.ld.app."; + strcat(app_param_name, path); + if (SystemReadParam(app_param_name, buffer, length) == 0) { + buffer[*length] = 0; + return true; + } + buffer[0] = 0; + return false; +} + +static bool get_ld_log_all_value(char *buffer, uint32_t *length) +{ + if (SystemReadParam("musl.log.ld.all", buffer, length) == 0) { + buffer[*length] = 0; + return true; + } + buffer[0] = 0; + return false; +} + +static inline void assign_ld_log_enable(char *param_value, const char *expect_value) +{ + ld_log_enable = (strcmp(param_value, expect_value) == 0); +} + +#endif + +void ld_log_reset() +{ +#if (defined(OHOS_ENABLE_PARAMETER)) + if (!is_musl_log_enable()) { + ld_log_enable = false; + return; + } + + char app_param_value[SYSPARAM_LENGTH]; + uint32_t app_param_value_len = SYSPARAM_LENGTH; + char all_param_value[SYSPARAM_LENGTH]; + uint32_t all_param_value_len = SYSPARAM_LENGTH; + + if (get_ld_log_app_value(app_param_value, &app_param_value_len)) { + assign_ld_log_enable(app_param_value, "true"); + } else { + if (get_ld_log_all_value(all_param_value, &all_param_value_len)) { + assign_ld_log_enable(all_param_value, "true"); + } else { + ld_log_enable = false; + } + } +#else + ld_log_enable = is_musl_log_enable(); +#endif +} + +bool get_ld_log_enable() +{ + return ld_log_enable; +} diff --git a/porting/linux/user/ldso/ld_log.h b/porting/linux/user/ldso/ld_log.h index 6ec9a63c..9c51975c 100644 --- a/porting/linux/user/ldso/ld_log.h +++ b/porting/linux/user/ldso/ld_log.h @@ -18,37 +18,56 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define LD_LOG_ERROR 1 #define LD_LOG_WARNING 2 #define LD_LOG_INFO 4 #define LD_LOG_DEBUG 8 -#define LD_LOG_LEVEL (LD_LOG_ERROR | LD_LOG_WARNING) +#define LD_LOG_LEVEL (LD_LOG_ERROR | LD_LOG_WARNING | LD_LOG_INFO) #define LD_LOG_TAG "MUSL-LDSO" -#if (defined(ENABLE_MUSL_LOG) && (LD_LOG_LEVEL & LD_LOG_ERROR)) -#define LD_LOGE(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_ERROR, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__)) +hidden bool get_ld_log_enable(); +hidden void ld_log_reset(); + +#if ((LD_LOG_LEVEL & LD_LOG_ERROR) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) +#define LD_LOGE(...) if (get_ld_log_enable()) { \ + (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_ERROR, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ +} #else #define LD_LOGE(...) #endif -#if (defined(ENABLE_MUSL_LOG) && (LD_LOG_LEVEL & LD_LOG_WARNING)) -#define LD_LOGW(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_WARN, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__)) +#if ((LD_LOG_LEVEL & LD_LOG_WARNING) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) +#define LD_LOGW(...) if (get_ld_log_enable()) { \ + (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_WARN, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ +} #else #define LD_LOGW(...) #endif -#if (defined(ENABLE_MUSL_LOG) && (LD_LOG_LEVEL & LD_LOG_INFO)) -#define LD_LOGI(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_INFO, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__)) +#if ((LD_LOG_LEVEL & LD_LOG_INFO) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) +#define LD_LOGI(...) if (get_ld_log_enable()) { \ + (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_INFO, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ +} #else #define LD_LOGI(...) #endif -#if (defined(ENABLE_MUSL_LOG) && (LD_LOG_LEVEL & LD_LOG_DEBUG)) -#define LD_LOGD(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_DEBUG, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__)) +#if (LD_LOG_LEVEL & LD_LOG_DEBUG) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG)) +#define LD_LOGD(...) if (get_ld_log_enable()) { \ + (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_DEBUG, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ +} #else #define LD_LOGD(...) #endif +#ifdef __cplusplus +} +#endif + #endif // LD_LOG_H diff --git a/porting/linux/user/src/hilog/hilog_adapter.c b/porting/linux/user/src/hilog/hilog_adapter.c index 361ec90f..4a203caa 100644 --- a/porting/linux/user/src/hilog/hilog_adapter.c +++ b/porting/linux/user/src/hilog/hilog_adapter.c @@ -16,27 +16,40 @@ #define _GNU_SOURCE #include -#include "hilog_common.h" -#include "vsnprintf_s_p.h" #include #include #include #include #include -#include #include #include #include +#include #include +#include "hilog_common.h" +#ifdef OHOS_ENABLE_PARAMETER +#include "sys_param.h" +#endif +#include "vsnprintf_s_p.h" + #define LOG_LEN 3 #define ERROR_FD 2 +#ifdef OHOS_ENABLE_PARAMETER +#define SYSPARAM_LENGTH 32 +#endif const int SOCKET_TYPE = SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC; const int INVALID_SOCKET = -1; const struct sockaddr_un SOCKET_ADDR = {AF_UNIX, SOCKET_FILE_DIR INPUT_SOCKET_NAME}; +static bool musl_log_enable = false; + +#ifdef OHOS_ENABLE_PARAMETER +static const char *param_name = "musl.log.enable"; +#endif + static int SendMessage(HilogMsg *header, const char *tag, uint16_t tagLen, const char *fmt, uint16_t fmtLen) { int socketFd = TEMP_FAILURE_RETRY(socket(AF_UNIX, SOCKET_TYPE, 0)); @@ -81,10 +94,6 @@ static int SendMessage(HilogMsg *header, const char *tag, uint16_t tagLen, const static int HiLogAdapterPrintArgs( const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *fmt, va_list ap) { - if (!HiLogAdapterIsLoggable(domain, tag, level)) { - return -1; - } - char buf[MAX_LOG_LEN] = {0}; vsnprintfp_s(buf, MAX_LOG_LEN, MAX_LOG_LEN - 1, true, fmt, ap); @@ -105,6 +114,10 @@ static int HiLogAdapterPrintArgs( int HiLogAdapterPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) { + if (!HiLogAdapterIsLoggable(domain, tag, level)) { + return -1; + } + int ret; va_list ap; va_start(ap, fmt); @@ -113,10 +126,40 @@ int HiLogAdapterPrint(LogType type, LogLevel level, unsigned int domain, const c return ret; } +bool is_musl_log_enable() +{ + if (getpid() == 1) { + return false; + } + return musl_log_enable; +} + bool HiLogAdapterIsLoggable(unsigned int domain, const char *tag, LogLevel level) { + if (!is_musl_log_enable()) { + return false; + } + if ((level <= LOG_LEVEL_MIN) || (level >= LOG_LEVEL_MAX) || tag == NULL) { return false; } return true; } + +void musl_log_reset() +{ +#if (defined(OHOS_ENABLE_PARAMETER)) + char param_value[SYSPARAM_LENGTH]; + uint32_t length = SYSPARAM_LENGTH; + if (SystemReadParam(param_name, param_value, &length) == 0) { + param_value[length] = 0; + if (strcmp(param_value, "true") == 0) { + musl_log_enable = true; + return; + } + } + musl_log_enable = false; +#elif (defined(ENABLE_MUSL_LOG)) + musl_log_enable = true; +#endif +} diff --git a/porting/linux/user/src/internal/hilog_adapter.h b/porting/linux/user/src/internal/hilog_adapter.h index cd6753a5..b0225117 100644 --- a/porting/linux/user/src/internal/hilog_adapter.h +++ b/porting/linux/user/src/internal/hilog_adapter.h @@ -47,4 +47,8 @@ hidden int HiLogAdapterPrint(LogType type, LogLevel level, unsigned int domain, __attribute__((__format__(os_log, 5, 6))); hidden bool HiLogAdapterIsLoggable(unsigned int domain, const char *tag, LogLevel level); + +hidden bool is_musl_log_enable(); +hidden void musl_log_reset(); + #endif // MUSL_HILOG_ADAPTER_H diff --git a/porting/linux/user/src/internal/musl_log.h b/porting/linux/user/src/internal/musl_log.h index 9825ebb8..62e15d3f 100644 --- a/porting/linux/user/src/internal/musl_log.h +++ b/porting/linux/user/src/internal/musl_log.h @@ -26,7 +26,7 @@ extern "C" { #define MUSL_LOG_DOMAIN 0xD003F00 #define MUSL_LOG_TAG "MUSL" -#ifdef ENABLE_MUSL_LOG +#if (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG)) #define MUSL_LOGE(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_ERROR, MUSL_LOG_DOMAIN, MUSL_LOG_TAG, __VA_ARGS__)) #define MUSL_LOGW(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_WARN, MUSL_LOG_DOMAIN, MUSL_LOG_TAG, __VA_ARGS__)) #define MUSL_LOGI(...) ((void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_INFO, MUSL_LOG_DOMAIN, MUSL_LOG_TAG, __VA_ARGS__)) -- GitLab