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_LNN_LOG_H 17 #define DSOFTBUS_LNN_LOG_H 18 19 #include "softbus_log.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 typedef enum { 25 LNN_INIT, 26 LNN_HEART_BEAT, 27 LNN_LEDGER, 28 LNN_BUILDER, 29 LNN_LANE, 30 LNN_QOS, 31 LNN_EVENT, 32 LNN_STATE, 33 LNN_META_NODE, 34 LNN_CLOCK, 35 LNN_TEST, 36 } LnnLogLabelEnum; 37 38 /* Keep consistent with labels */ 39 static const SoftBusLogLabel LNN_LABELS[MODULE_DOMAIN_MAX_LEN] = { 40 { LNN_INIT, 0xd005780, "LnnInit" }, 41 { LNN_HEART_BEAT, 0xd005781, "LnnHeartBeat"}, 42 { LNN_LEDGER, 0xd005782, "LnnLedger" }, 43 { LNN_BUILDER, 0xd005783, "LnnBuilder" }, 44 { LNN_LANE, 0xd005784, "LnnLane" }, 45 { LNN_QOS, 0xd005785, "LnnQos" }, 46 { LNN_EVENT, 0xd005786, "LnnEvent" }, 47 { LNN_STATE, 0xd005787, "LnnState" }, 48 { LNN_META_NODE, 0xd005788, "LnnMetaNode" }, 49 { LNN_CLOCK, 0xd005789, "LnnClock" }, 50 { LNN_TEST, DOMAIN_ID_TEST, "LnnTest" }, 51 }; 52 53 #if defined(SOFTBUS_LITEOS_M) 54 #define LNN_LOGF(label, fmt, ...) SOFTBUS_LOGF_INNER(label, fmt, ##__VA_ARGS__) 55 #define LNN_LOGE(label, fmt, ...) SOFTBUS_LOGE_INNER(label, fmt, ##__VA_ARGS__) 56 #define LNN_LOGW(label, fmt, ...) SOFTBUS_LOGW_INNER(label, fmt, ##__VA_ARGS__) 57 #define LNN_LOGI(label, fmt, ...) SOFTBUS_LOGI_INNER(label, fmt, ##__VA_ARGS__) 58 #define LNN_LOGD(label, fmt, ...) SOFTBUS_LOGD_INNER(label, fmt, ##__VA_ARGS__) 59 #else 60 #define LNN_LOGF(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_FATAL, LNN_LABELS[label], fmt, ##__VA_ARGS__) 61 #define LNN_LOGE(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_ERROR, LNN_LABELS[label], fmt, ##__VA_ARGS__) 62 #define LNN_LOGW(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_WARN, LNN_LABELS[label], fmt, ##__VA_ARGS__) 63 #define LNN_LOGI(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_INFO, LNN_LABELS[label], fmt, ##__VA_ARGS__) 64 #define LNN_LOGD(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_DEBUG, LNN_LABELS[label], fmt, ##__VA_ARGS__) 65 #endif // SOFTBUS_LITEOS_M 66 67 #define LNN_CHECK_AND_RETURN_RET_LOGW(cond, ret, label, fmt, ...) \ 68 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, LNN_LOGW, label, fmt, ##__VA_ARGS__) 69 #define LNN_CHECK_AND_RETURN_RET_LOGE(cond, ret, label, fmt, ...) \ 70 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, LNN_LOGE, label, fmt, ##__VA_ARGS__) 71 #define LNN_CHECK_AND_RETURN_LOGW(cond, label, fmt, ...) \ 72 CHECK_AND_RETURN_LOG_INNER(cond, LNN_LOGW, label, fmt, ##__VA_ARGS__) 73 #define LNN_CHECK_AND_RETURN_LOGE(cond, label, fmt, ...) \ 74 CHECK_AND_RETURN_LOG_INNER(cond, LNN_LOGE, label, fmt, ##__VA_ARGS__) 75 76 #ifdef __cplusplus 77 } 78 #endif 79 #endif // DSOFTBUS_LNN_LOG_H 80