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 OHOS_ABILITY_BASE_ABILITY_BASE_HILOG_WRAPPER_H 17 #define OHOS_ABILITY_BASE_ABILITY_BASE_HILOG_WRAPPER_H 18 19 #define ABILITYBASE_CONFIG_HILOG 20 #ifdef ABILITYBASE_CONFIG_HILOG 21 #include "hilog/log.h" 22 23 #ifdef ABILITYBASE_LOGF 24 #undef ABILITYBASE_LOGF 25 #endif 26 27 #ifdef ABILITYBASE_LOGE 28 #undef ABILITYBASE_LOGE 29 #endif 30 31 #ifdef ABILITYBASE_LOGW 32 #undef ABILITYBASE_LOGW 33 #endif 34 35 #ifdef ABILITYBASE_LOGI 36 #undef ABILITYBASE_LOGI 37 #endif 38 39 #ifdef ABILITYBASE_LOGD 40 #undef ABILITYBASE_LOGD 41 #endif 42 43 #ifndef ABILITYBASE_LOG_DOMAIN 44 #define ABILITYBASE_LOG_DOMAIN 0xD001305 45 #endif 46 47 #ifndef ABILITYBASE_LOG_TAG 48 #define ABILITYBASE_LOG_TAG "Base" 49 #endif 50 51 #define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 52 53 #define ABILITYBASE_LOGF(fmt, ...) \ 54 ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, ABILITYBASE_LOG_DOMAIN, ABILITYBASE_LOG_TAG, \ 55 "[%{public}s(%{public}s:%{public}d)]" fmt, \ 56 __FILENAME__, \ 57 __FUNCTION__, \ 58 __LINE__, \ 59 ##__VA_ARGS__)) 60 #define ABILITYBASE_LOGE(fmt, ...) \ 61 ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, ABILITYBASE_LOG_DOMAIN, ABILITYBASE_LOG_TAG, \ 62 "[%{public}s(%{public}s:%{public}d)]" fmt, \ 63 __FILENAME__, \ 64 __FUNCTION__, \ 65 __LINE__, \ 66 ##__VA_ARGS__)) 67 #define ABILITYBASE_LOGW(fmt, ...) \ 68 ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, ABILITYBASE_LOG_DOMAIN, ABILITYBASE_LOG_TAG, \ 69 "[%{public}s(%{public}s:%{public}d)]" fmt, \ 70 __FILENAME__, \ 71 __FUNCTION__, \ 72 __LINE__, \ 73 ##__VA_ARGS__)) 74 #define ABILITYBASE_LOGI(fmt, ...) \ 75 ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, ABILITYBASE_LOG_DOMAIN, ABILITYBASE_LOG_TAG, \ 76 "[%{public}s(%{public}s:%{public}d)]" fmt, \ 77 __FILENAME__, \ 78 __FUNCTION__, \ 79 __LINE__, \ 80 ##__VA_ARGS__)) 81 #define ABILITYBASE_LOGD(fmt, ...) \ 82 ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, ABILITYBASE_LOG_DOMAIN, ABILITYBASE_LOG_TAG, \ 83 "[%{public}s(%{public}s:%{public}d)]" fmt, \ 84 __FILENAME__, \ 85 __FUNCTION__, \ 86 __LINE__, \ 87 ##__VA_ARGS__)) 88 #else 89 90 #define ABILITYBASE_LOGF(...) 91 #define ABILITYBASE_LOGE(...) 92 #define ABILITYBASE_LOGW(...) 93 #define ABILITYBASE_LOGI(...) 94 #define ABILITYBASE_LOGD(...) 95 #endif // ABILITYBASE_CONFIG_HILOG 96 97 #endif // OHOS_ABILITY_BASE_ABILITY_BASE_HILOG_WRAPPER_H 98