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_DISC_LOG_H 17 #define DSOFTBUS_DISC_LOG_H 18 19 #include "softbus_log.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 typedef enum { 25 DISC_INIT, 26 DISC_CONTROL, 27 DISC_LNN, 28 DISC_BLE, 29 DISC_BLE_ADAPTER, 30 DISC_COAP, 31 DISC_DFINDER, 32 DISC_ABILITY, 33 DISC_USB, 34 DISC_USB_ADAPTER, 35 DISC_SDK, 36 DISC_BROADCAST, 37 DISC_ACTION, 38 DISC_EVENT, 39 DISC_VIRLINK, 40 DISC_TEST, 41 } DiscLogLabelEnum; 42 43 /* Keep consistent with labels */ 44 static const SoftBusLogLabel DISC_LABELS[MODULE_DOMAIN_MAX_LEN] = { 45 { DISC_INIT, 0xd0057a0, "DiscInit" }, 46 { DISC_CONTROL, 0xd0057a1, "DiscControl" }, 47 { DISC_LNN, 0xd0057a2, "DiscLnn" }, 48 { DISC_BLE, 0xd0057a3, "DiscBle" }, 49 { DISC_BLE_ADAPTER, 0xd0057a4, "DiscBleAdapter"}, 50 { DISC_COAP, 0xd0057a5, "DiscCoap" }, 51 { DISC_DFINDER, 0xd0057a6, "DiscDfinder" }, 52 { DISC_ABILITY, 0xd0057a7, "DiscAbility" }, 53 { DISC_USB, 0xd0057a8, "DiscUsb" }, 54 { DISC_USB_ADAPTER, 0xd0057a9, "DiscUsbAdapter"}, 55 { DISC_SDK, 0xd0057aa, "DiscSdk" }, 56 { DISC_BROADCAST, 0xd0057ab, "DiscBroadcast" }, 57 { DISC_ACTION, 0xd0057ac, "DiscAction" }, 58 { DISC_EVENT, 0xd0057ad, "DiscEvent" }, 59 { DISC_VIRLINK, 0xd0057ae, "DiscVirlink" }, 60 { DISC_TEST, DOMAIN_ID_TEST, "DiscTest" }, 61 }; 62 63 #if defined(SOFTBUS_LITEOS_M) 64 #define DISC_LOGF(label, fmt, ...) SOFTBUS_LOGF_INNER(label, fmt, ##__VA_ARGS__) 65 #define DISC_LOGE(label, fmt, ...) SOFTBUS_LOGE_INNER(label, fmt, ##__VA_ARGS__) 66 #define DISC_LOGW(label, fmt, ...) SOFTBUS_LOGW_INNER(label, fmt, ##__VA_ARGS__) 67 #define DISC_LOGI(label, fmt, ...) SOFTBUS_LOGI_INNER(label, fmt, ##__VA_ARGS__) 68 #define DISC_LOGD(label, fmt, ...) SOFTBUS_LOGD_INNER(label, fmt, ##__VA_ARGS__) 69 #else 70 #define DISC_LOGF(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_FATAL, DISC_LABELS[label], fmt, ##__VA_ARGS__) 71 #define DISC_LOGE(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_ERROR, DISC_LABELS[label], fmt, ##__VA_ARGS__) 72 #define DISC_LOGW(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_WARN, DISC_LABELS[label], fmt, ##__VA_ARGS__) 73 #define DISC_LOGI(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_INFO, DISC_LABELS[label], fmt, ##__VA_ARGS__) 74 #define DISC_LOGD(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_DEBUG, DISC_LABELS[label], fmt, ##__VA_ARGS__) 75 #endif // SOFTBUS_LITEOS_M 76 77 #define DISC_CHECK_AND_RETURN_RET_LOGD(cond, ret, label, fmt, ...) \ 78 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, DISC_LOGD, label, fmt, ##__VA_ARGS__) 79 #define DISC_CHECK_AND_RETURN_RET_LOGW(cond, ret, label, fmt, ...) \ 80 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, DISC_LOGW, label, fmt, ##__VA_ARGS__) 81 #define DISC_CHECK_AND_RETURN_RET_LOGE(cond, ret, label, fmt, ...) \ 82 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, DISC_LOGE, label, fmt, ##__VA_ARGS__) 83 #define DISC_CHECK_AND_RETURN_LOGD(cond, label, fmt, ...) \ 84 CHECK_AND_RETURN_LOG_INNER(cond, DISC_LOGD, label, fmt, ##__VA_ARGS__) 85 #define DISC_CHECK_AND_RETURN_LOGW(cond, label, fmt, ...) \ 86 CHECK_AND_RETURN_LOG_INNER(cond, DISC_LOGW, label, fmt, ##__VA_ARGS__) 87 #define DISC_CHECK_AND_RETURN_LOGE(cond, label, fmt, ...) \ 88 CHECK_AND_RETURN_LOG_INNER(cond, DISC_LOGE, label, fmt, ##__VA_ARGS__) 89 90 #ifdef __cplusplus 91 } 92 #endif 93 #endif // DSOFTBUS_DISC_LOG_H 94