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 HILOG_HILOG_WRAPPER_H 17 #define HILOG_HILOG_WRAPPER_H 18 19 #define LOG_TAG "HilogApiMgr" 20 21 #if defined(__LITEOS_M__) 22 #include "log.h" 23 #else 24 #include "hilog/log.h" 25 #endif 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif // __cplusplus 30 31 #define FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 32 #define FORMATED(fmt, ...) "[%s] %s# " fmt, FILENAME, __FUNCTION__, ##__VA_ARGS__ 33 34 #ifdef HILOG_HILOGD 35 #undef HILOG_HILOGD 36 #endif 37 38 #ifdef HILOG_HILOGI 39 #undef HILOG_HILOGI 40 #endif 41 42 #ifdef HILOG_HILOGW 43 #undef HILOG_HILOGW 44 #endif 45 46 #ifdef HILOG_HILOGE 47 #undef HILOG_HILOGE 48 #endif 49 50 #ifdef HILOG_HILOGF 51 #undef HILOG_HILOGF 52 #endif 53 54 #ifdef __LITEOS_M__ 55 #define HILOG_HILOGD(...) HILOG_DEBUG(HILOG_MODULE_POWERMGR, __VA_ARGS__) 56 #define HILOG_HILOGI(...) HILOG_INFO(HILOG_MODULE_POWERMGR, __VA_ARGS__) 57 #define HILOG_HILOGW(...) HILOG_WARN(HILOG_MODULE_POWERMGR, __VA_ARGS__) 58 #define HILOG_HILOGE(...) HILOG_ERROR(HILOG_MODULE_POWERMGR, __VA_ARGS__) 59 #define HILOG_HILOGF(...) HILOG_FATAL(HILOG_MODULE_POWERMGR, __VA_ARGS__) 60 #else // !__LITEOS_M__ 61 #define HILOG_HILOGD(...) HILOG_DEBUG(LOG_CORE, FORMATED(__VA_ARGS__)) 62 #define HILOG_HILOGI(...) HILOG_INFO(LOG_CORE, FORMATED(__VA_ARGS__)) 63 #define HILOG_HILOGW(...) HILOG_WARN(LOG_CORE, FORMATED(__VA_ARGS__)) 64 #define HILOG_HILOGE(...) HILOG_ERROR(LOG_CORE, FORMATED(__VA_ARGS__)) 65 #define HILOG_HILOGF(...) HILOG_FATAL(LOG_CORE, FORMATED(__VA_ARGS__)) 66 #endif // __LITEOS_M__ 67 68 #ifdef __cplusplus 69 } 70 #endif // __cplusplus 71 #endif // HILOG_HILOG_WRAPPER_H 72