• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 DSOFTBUS_CONN_LOG_H
17 #define DSOFTBUS_CONN_LOG_H
18 
19 #include "softbus_log.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 typedef enum {
25     CONN_INIT,
26     CONN_BLE,
27     CONN_BR,
28     CONN_COMMON,
29     CONN_WIFI_DIRECT,
30     CONN_NEARBY,
31     CONN_BLE_DIRECT,
32     CONN_BROADCAST,
33     CONN_NEWIP,
34     CONN_ACTION,
35     CONN_SLE,
36     CONN_EVENT,
37     CONN_PROXY,
38     CONN_TEST,
39 } ConnLogLabelEnum;
40 
41 /* Keep consistent with labels 0xd005760 - 0xd00577f*/
42 static const SoftBusLogLabel CONN_LABELS[MODULE_DOMAIN_MAX_LEN] = {
43     {CONN_INIT,         0xd005760,      "ConnInit"},
44     {CONN_BLE,          0xd005761,      "ConnBle"},
45     {CONN_BR,           0xd005762,      "ConnBr"},
46     {CONN_COMMON,       0xd005763,      "ConnCommon"},
47     {CONN_WIFI_DIRECT,  0xd005764,      "ConnWD"},
48     {CONN_NEARBY,       0xd005765,      "ConnNearby"},
49     {CONN_BLE_DIRECT,   0xd005766,      "ConnBD"},
50     {CONN_BROADCAST,    0xd005767,      "ConnBC"},
51     {CONN_NEWIP,        0xd005768,      "ConnNewIp"},
52     {CONN_ACTION,       0xd005769,      "ConnAction"},
53     {CONN_SLE,          0xd005761,      "ConnSle"},
54     {CONN_EVENT,        0xd00576a,      "ConnEvent"},
55     {CONN_PROXY,        0xd005762,      "ConnProxy"},
56     {CONN_TEST,         DOMAIN_ID_TEST, "ConnTest"},
57 };
58 
59 #if defined(SOFTBUS_LITEOS_M)
60 #define CONN_LOGF(label, fmt, ...) SOFTBUS_LOGF_INNER(label, fmt, ##__VA_ARGS__)
61 #define CONN_LOGE(label, fmt, ...) SOFTBUS_LOGE_INNER(label, fmt, ##__VA_ARGS__)
62 #define CONN_LOGW(label, fmt, ...) SOFTBUS_LOGW_INNER(label, fmt, ##__VA_ARGS__)
63 #define CONN_LOGI(label, fmt, ...) SOFTBUS_LOGI_INNER(label, fmt, ##__VA_ARGS__)
64 #define CONN_LOGD(label, fmt, ...) SOFTBUS_LOGD_INNER(label, fmt, ##__VA_ARGS__)
65 #else
66 #define CONN_LOGF(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_FATAL, CONN_LABELS[label], fmt, ##__VA_ARGS__)
67 #define CONN_LOGE(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_ERROR, CONN_LABELS[label], fmt, ##__VA_ARGS__)
68 #define CONN_LOGW(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_WARN, CONN_LABELS[label], fmt, ##__VA_ARGS__)
69 #define CONN_LOGI(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_INFO, CONN_LABELS[label], fmt, ##__VA_ARGS__)
70 #define CONN_LOGD(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_DEBUG, CONN_LABELS[label], fmt, ##__VA_ARGS__)
71 #endif // SOFTBUS_LITEOS_M
72 
73 #define CONN_CHECK_AND_RETURN_RET_LOGW(cond, ret, label, fmt, ...) \
74     CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGW, label, fmt, ##__VA_ARGS__)
75 #define CONN_CHECK_AND_RETURN_RET_LOGE(cond, ret, label, fmt, ...) \
76     CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGE, label, fmt, ##__VA_ARGS__)
77 #define CONN_CHECK_AND_RETURN_RET_LOGI(cond, ret, label, fmt, ...) \
78     CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGI, label, fmt, ##__VA_ARGS__)
79 #define CONN_CHECK_AND_RETURN_RET_LOGD(cond, ret, label, fmt, ...) \
80     CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGD, label, fmt, ##__VA_ARGS__)
81 
82 #define CONN_CHECK_AND_RETURN_LOGW(cond, label, fmt, ...) \
83     CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGW, label, fmt, ##__VA_ARGS__)
84 #define CONN_CHECK_AND_RETURN_LOGE(cond, label, fmt, ...) \
85     CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGE, label, fmt, ##__VA_ARGS__)
86 #define CONN_CHECK_AND_RETURN_LOGI(cond, label, fmt, ...) \
87     CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGI, label, fmt, ##__VA_ARGS__)
88 #define CONN_CHECK_AND_RETURN_LOGD(cond, label, fmt, ...) \
89     CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGD, label, fmt, ##__VA_ARGS__)
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif // DSOFTBUS_CONN_LOG_H
95