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 hidden bool is_dlopen_debug_enable(); 39 40 #if ((LD_LOG_LEVEL & LD_LOG_ERROR) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) 41 #define LD_LOGE(...) (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_ERROR, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); 42 #else 43 #define LD_LOGE(...) 44 #endif 45 46 #if ((LD_LOG_LEVEL & LD_LOG_WARNING) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) 47 #define LD_LOGW(...) if (get_ld_log_enable()) { \ 48 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_WARN, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 49 } 50 #else 51 #define LD_LOGW(...) 52 #endif 53 54 #if ((LD_LOG_LEVEL & LD_LOG_INFO) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG))) 55 #define LD_LOGI(...) if (get_ld_log_enable()) { \ 56 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_INFO, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 57 } 58 #else 59 #define LD_LOGI(...) 60 #endif 61 62 #if (LD_LOG_LEVEL & LD_LOG_DEBUG) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG)) 63 #define LD_LOGD(...) if (get_ld_log_enable()) { \ 64 (void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_DEBUG, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \ 65 } 66 #else 67 #define LD_LOGD(...) 68 #endif 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 #endif // LD_LOG_H 75