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_TEST, 36 } ConnLogLabelEnum; 37 38 /* Keep consistent with labels 0xd005760 - 0xd00577f*/ 39 static const SoftBusLogLabel CONN_LABELS[MODULE_DOMAIN_MAX_LEN] = { 40 {CONN_INIT, 0xd005760, "ConnInit"}, 41 {CONN_BLE, 0xd005761, "ConnBle"}, 42 {CONN_BR, 0xd005762, "ConnBr"}, 43 {CONN_COMMON, 0xd005763, "ConnCommon"}, 44 {CONN_WIFI_DIRECT, 0xd005764, "ConnWD"}, 45 {CONN_NEARBY, 0xd005765, "ConnNearby"}, 46 {CONN_BLE_DIRECT, 0xd005766, "ConnBD"}, 47 {CONN_BROADCAST, 0xd005767, "ConnBC"}, 48 {CONN_NEWIP, 0xd005768, "ConnNewIp"}, 49 {CONN_ACTION, 0xd005769, "ConnAction"}, 50 {CONN_TEST, DOMAIN_ID_TEST, "ConnTest"}, 51 }; 52 53 #if defined(SOFTBUS_LITEOS_M) 54 #define CONN_LOGF(label, fmt, ...) SOFTBUS_LOGF_INNER(label, fmt, ##__VA_ARGS__) 55 #define CONN_LOGE(label, fmt, ...) SOFTBUS_LOGE_INNER(label, fmt, ##__VA_ARGS__) 56 #define CONN_LOGW(label, fmt, ...) SOFTBUS_LOGW_INNER(label, fmt, ##__VA_ARGS__) 57 #define CONN_LOGI(label, fmt, ...) SOFTBUS_LOGI_INNER(label, fmt, ##__VA_ARGS__) 58 #define CONN_LOGD(label, fmt, ...) SOFTBUS_LOGD_INNER(label, fmt, ##__VA_ARGS__) 59 #else 60 #define CONN_LOGF(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_FATAL, CONN_LABELS[label], fmt, ##__VA_ARGS__) 61 #define CONN_LOGE(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_ERROR, CONN_LABELS[label], fmt, ##__VA_ARGS__) 62 #define CONN_LOGW(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_WARN, CONN_LABELS[label], fmt, ##__VA_ARGS__) 63 #define CONN_LOGI(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_INFO, CONN_LABELS[label], fmt, ##__VA_ARGS__) 64 #define CONN_LOGD(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_DEBUG, CONN_LABELS[label], fmt, ##__VA_ARGS__) 65 #endif // SOFTBUS_LITEOS_M 66 67 #define CONN_CHECK_AND_RETURN_RET_LOGW(cond, ret, label, fmt, ...) \ 68 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGW, label, fmt, ##__VA_ARGS__) 69 #define CONN_CHECK_AND_RETURN_RET_LOGE(cond, ret, label, fmt, ...) \ 70 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGE, label, fmt, ##__VA_ARGS__) 71 #define CONN_CHECK_AND_RETURN_RET_LOGI(cond, ret, label, fmt, ...) \ 72 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGI, label, fmt, ##__VA_ARGS__) 73 #define CONN_CHECK_AND_RETURN_RET_LOGD(cond, ret, label, fmt, ...) \ 74 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, CONN_LOGD, label, fmt, ##__VA_ARGS__) 75 76 #define CONN_CHECK_AND_RETURN_LOGW(cond, label, fmt, ...) \ 77 CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGW, label, fmt, ##__VA_ARGS__) 78 #define CONN_CHECK_AND_RETURN_LOGE(cond, label, fmt, ...) \ 79 CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGE, label, fmt, ##__VA_ARGS__) 80 #define CONN_CHECK_AND_RETURN_LOGI(cond, label, fmt, ...) \ 81 CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGI, label, fmt, ##__VA_ARGS__) 82 #define CONN_CHECK_AND_RETURN_LOGD(cond, label, fmt, ...) \ 83 CHECK_AND_RETURN_LOG_INNER(cond, CONN_LOGD, label, fmt, ##__VA_ARGS__) 84 85 #ifdef __cplusplus 86 } 87 #endif 88 #endif // DSOFTBUS_CONN_LOG_H 89