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 BLUETOOTH_LOG_H 17#define BLUETOOTH_LOG_H 18 19#undef LOG_DOMAIN 20#define LOG_DOMAIN 0xD000101 21#ifndef LOG_TAG 22#define LOG_TAG "Bluetooth" 23#endif 24 25#include "hilog/log.h" 26 27#ifdef HILOGF 28#undef HILOGF 29#endif 30 31#ifdef HILOGE 32#undef HILOGE 33#endif 34 35#ifdef HILOGW 36#undef HILOGW 37#endif 38 39#ifdef HILOGI 40#undef HILOGI 41#endif 42 43#ifdef HILOGD 44#undef HILOGD 45#endif 46 47#define HILOGD(fmt, ...) \ 48 HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 49 __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 50#define HILOGI(fmt, ...) \ 51 HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 52 __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 53#define HILOGW(fmt, ...) \ 54 HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 55 __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 56#define HILOGE(fmt, ...) \ 57 HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 58 __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 59#define HILOGF(fmt, ...) \ 60 HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, \ 61 __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 62 63#ifdef CHECK_AND_RETURN_LOG 64#undef CHECK_AND_RETURN_LOG 65#endif 66 67#define CHECK_AND_RETURN_LOG(cond, fmt, ...) \ 68 do { \ 69 if (!(cond)) { \ 70 HILOGE(fmt, ##__VA_ARGS__); \ 71 return; \ 72 } \ 73 } while (0) 74 75#ifdef CHECK_AND_RETURN_LOG_RET 76#undef CHECK_AND_RETURN_LOG_RET 77#endif 78 79#define CHECK_AND_RETURN_LOG_RET(cond, ret, fmt, ...) \ 80 do { \ 81 if (!(cond)) { \ 82 HILOGE(fmt, ##__VA_ARGS__); \ 83 return ret; \ 84 } \ 85 } while (0) 86 87#endif // BLUETOOTH_LOG_H 88