1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LD_LOG_H 17 #define LD_LOG_H 18 19 #include <musl_log.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define LD_LOG_ERROR 1 26 #define LD_LOG_WARNING 2 27 #define LD_LOG_INFO 4 28 #define LD_LOG_DEBUG 8 29 30 #define LD_LOG_LEVEL (LD_LOG_ERROR | LD_LOG_WARNING | LD_LOG_INFO) 31 32 #define LD_LOG_TAG "MUSL-LDSO" 33 34 hidden bool get_ld_log_enable(); 35 hidden void ld_log_reset(); 36 37 hidden bool is_dlclose_debug_enable(); 38 39 #if ((LD_LOG_LEVEL & LD_LOG_ERROR) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) 40 #define LD_LOGE(...) if (get_ld_log_enable()) { \ 41 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_ERROR, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 42 } 43 #else 44 #define LD_LOGE(...) 45 #endif 46 47 #if ((LD_LOG_LEVEL & LD_LOG_WARNING) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) 48 #define LD_LOGW(...) if (get_ld_log_enable()) { \ 49 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_WARN, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 50 } 51 #else 52 #define LD_LOGW(...) 53 #endif 54 55 #if ((LD_LOG_LEVEL & LD_LOG_INFO) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) 56 #define LD_LOGI(...) if (get_ld_log_enable()) { \ 57 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_INFO, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 58 } 59 #else 60 #define LD_LOGI(...) 61 #endif 62 63 #if (LD_LOG_LEVEL & LD_LOG_DEBUG) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG)) 64 #define LD_LOGD(...) if (get_ld_log_enable()) { \ 65 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_DEBUG, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 66 } 67 #else 68 #define LD_LOGD(...) 69 #endif 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif // LD_LOG_H 76