• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define CONFIG_HILOG
20 #ifdef CONFIG_HILOG
21 #include "hilog/log.h"
22 
23 #ifdef HILOGF
24 #undef HILOGF
25 #endif
26 
27 #ifdef HILOGE
28 #undef HILOGE
29 #endif
30 
31 #ifdef HILOGW
32 #undef HILOGW
33 #endif
34 
35 #ifdef HILOGI
36 #undef HILOGI
37 #endif
38 
39 #ifdef HILOGD
40 #undef HILOGD
41 #endif
42 
43 #ifndef BT_LOG_DOMAIN
44 #define BT_LOG_DOMAIN 0xD000101
45 #endif
46 
47 #ifndef BT_LOG_TAG
48 #define BT_LOG_TAG "Bluetooth"
49 #endif
50 
51 #ifdef LOG_LABEL
52 #undef LOG_LABEL
53 #endif
54 
55 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, BT_LOG_DOMAIN, BT_LOG_TAG};
56 
57 #define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
58 
59 #define HILOGF(fmt, ...)                 \
60     (void)OHOS::HiviewDFX::HiLog::Fatal( \
61         LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
62 #define HILOGE(fmt, ...)                 \
63     (void)OHOS::HiviewDFX::HiLog::Error( \
64         LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
65 #define HILOGW(fmt, ...)                \
66     (void)OHOS::HiviewDFX::HiLog::Warn( \
67         LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
68 #define HILOGI(fmt, ...)                \
69     (void)OHOS::HiviewDFX::HiLog::Info( \
70         LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
71 #define HILOGD(fmt, ...)                 \
72     (void)OHOS::HiviewDFX::HiLog::Debug( \
73         LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
74 #else
75 
76 #define HILOGF(...)
77 #define HILOGE(...)
78 #define HILOGW(...)
79 #define HILOGI(...)
80 #define HILOGD(...)
81 #endif  // CONFIG_HILOG
82 
83 #endif  // BLUETOOTH_LOG_H
84