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_AUTH_LOG_H 17 #define DSOFTBUS_AUTH_LOG_H 18 19 #include "softbus_log.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 typedef enum { 25 AUTH_INIT, 26 AUTH_HICHAIN, 27 AUTH_CONN, 28 AUTH_FSM, 29 AUTH_KEY, 30 AUTH_TEST, 31 } AuthLogLabelEnum; 32 33 /* Keep consistent with labels */ 34 static const SoftBusLogLabel AUTH_LABELS[MODULE_DOMAIN_MAX_LEN] = { 35 { AUTH_INIT, 0xd005720, "AuthInit" }, 36 { AUTH_HICHAIN, 0xd005721, "AuthHiChain" }, 37 { AUTH_CONN, 0xd005722, "AuthConn" }, 38 { AUTH_FSM, 0xd005723, "AuthFsm" }, 39 { AUTH_KEY, 0xd005724, "AuthKey" }, 40 { AUTH_TEST, DOMAIN_ID_TEST, "AuthTest" }, 41 }; 42 43 #if defined(SOFTBUS_LITEOS_M) 44 #define AUTH_LOGF(label, fmt, ...) SOFTBUS_LOGF_INNER(label, fmt, ##__VA_ARGS__) 45 #define AUTH_LOGE(label, fmt, ...) SOFTBUS_LOGE_INNER(label, fmt, ##__VA_ARGS__) 46 #define AUTH_LOGW(label, fmt, ...) SOFTBUS_LOGW_INNER(label, fmt, ##__VA_ARGS__) 47 #define AUTH_LOGI(label, fmt, ...) SOFTBUS_LOGI_INNER(label, fmt, ##__VA_ARGS__) 48 #define AUTH_LOGD(label, fmt, ...) SOFTBUS_LOGD_INNER(label, fmt, ##__VA_ARGS__) 49 #else 50 #define AUTH_LOGF(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_FATAL, AUTH_LABELS[label], fmt, ##__VA_ARGS__) 51 #define AUTH_LOGE(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_ERROR, AUTH_LABELS[label], fmt, ##__VA_ARGS__) 52 #define AUTH_LOGW(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_WARN, AUTH_LABELS[label], fmt, ##__VA_ARGS__) 53 #define AUTH_LOGI(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_INFO, AUTH_LABELS[label], fmt, ##__VA_ARGS__) 54 #define AUTH_LOGD(label, fmt, ...) SOFTBUS_LOG_INNER(LOG_DEBUG, AUTH_LABELS[label], fmt, ##__VA_ARGS__) 55 #endif // SOFTBUS_LITEOS_M 56 57 #define AUTH_CHECK_AND_RETURN_RET_LOGW(cond, ret, label, fmt, ...) \ 58 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, AUTH_LOGW, label, fmt, ##__VA_ARGS__) 59 #define AUTH_CHECK_AND_RETURN_RET_LOGE(cond, ret, label, fmt, ...) \ 60 CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, AUTH_LOGE, label, fmt, ##__VA_ARGS__) 61 #define AUTH_CHECK_AND_RETURN_LOGW(cond, label, fmt, ...) \ 62 CHECK_AND_RETURN_LOG_INNER(cond, AUTH_LOGW, label, fmt, ##__VA_ARGS__) 63 #define AUTH_CHECK_AND_RETURN_LOGE(cond, label, fmt, ...) \ 64 CHECK_AND_RETURN_LOG_INNER(cond, AUTH_LOGE, label, fmt, ##__VA_ARGS__) 65 66 #ifdef __cplusplus 67 } 68 #endif 69 #endif // DSOFTBUS_AUTH_LOG_H 70