1 /* 2 * Copyright (C) 2021 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 LOG_H 17 #define LOG_H 18 19 #define LOG_DOMAIN 0xD000102 20 #define LOG_TAG "Bluetooth" 21 22 #include "hilog/log.h" 23 24 #ifdef HILOGF 25 #undef HILOGF 26 #endif 27 28 #ifdef HILOGE 29 #undef HILOGE 30 #endif 31 32 #ifdef HILOGW 33 #undef HILOGW 34 #endif 35 36 #ifdef HILOGI 37 #undef HILOGI 38 #endif 39 40 #ifdef HILOGD 41 #undef HILOGD 42 #endif 43 44 #define FILENAME_SHORT (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 45 46 #define HILOGD(fmt, ...) \ 47 HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 48 FILENAME_SHORT, __FUNCTION__, __LINE__, ##__VA_ARGS__) 49 #define HILOGI(fmt, ...) \ 50 HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 51 FILENAME_SHORT, __FUNCTION__, __LINE__, ##__VA_ARGS__) 52 #define HILOGW(fmt, ...) \ 53 HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 54 FILENAME_SHORT, __FUNCTION__, __LINE__, ##__VA_ARGS__) 55 #define HILOGE(fmt, ...) \ 56 HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 57 FILENAME_SHORT, __FUNCTION__, __LINE__, ##__VA_ARGS__) 58 #define HILOGF(fmt, ...) \ 59 HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 60 FILENAME_SHORT, __FUNCTION__, __LINE__, ##__VA_ARGS__) 61 62 #ifdef LOG_DEBUG 63 #undef LOG_DEBUG 64 #endif 65 66 #ifdef LOG_INFO 67 #undef LOG_INFO 68 #endif 69 70 #ifdef LOG_WARN 71 #undef LOG_WARN 72 #endif 73 74 #ifdef LOG_ERROR 75 #undef LOG_ERROR 76 #endif 77 78 #ifdef LOG_FATAL 79 #undef LOG_FATAL 80 #endif 81 82 #define LOG_DEBUG(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__) 83 #define LOG_INFO(...) HILOG_INFO(LOG_CORE, __VA_ARGS__) 84 #define LOG_WARN(...) HILOG_WARN(LOG_CORE, __VA_ARGS__) 85 #define LOG_ERROR(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__) 86 #define LOG_FATAL(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__) 87 88 #endif // LOG_H 89