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 IAM_LOGGER_H 17 #define IAM_LOGGER_H 18 19 #include "hilog/log.h" 20 namespace OHOS { 21 namespace UserIam { 22 namespace Common { 23 #ifdef __FILE_NAME__ 24 #define USER_AUTH_FILE __FILE_NAME__ 25 #else 26 #define USER_AUTH_FILE (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 27 #endif 28 29 #ifdef LOG_DOMAIN 30 #undef LOG_DOMAIN 31 #endif 32 33 #define LOG_DOMAIN 0xD002402 34 35 #ifdef LOG_TAG 36 #undef LOG_TAG 37 #endif 38 39 #define USER_AUTH_DEBUG(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__) 40 #define USER_AUTH_INFO(...) HILOG_INFO(LOG_CORE, __VA_ARGS__) 41 #define USER_AUTH_WARN(...) HILOG_WARN(LOG_CORE, __VA_ARGS__) 42 #define USER_AUTH_ERROR(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__) 43 #define USER_AUTH_FATAL(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__) 44 45 #define ARGS(fmt, ...) "[%{public}s@%{public}s:%{public}d] " fmt, __FUNCTION__, USER_AUTH_FILE, __LINE__, ##__VA_ARGS__ 46 #define USER_LOG(level, ...) USER_AUTH_##level(ARGS(__VA_ARGS__)) 47 48 #define IAM_LOGD(...) USER_LOG(DEBUG, __VA_ARGS__) 49 #define IAM_LOGI(...) USER_LOG(INFO, __VA_ARGS__) 50 #define IAM_LOGW(...) USER_LOG(WARN, __VA_ARGS__) 51 #define IAM_LOGE(...) USER_LOG(ERROR, __VA_ARGS__) 52 #define IAM_LOGF(...) USER_LOG(FATAL, __VA_ARGS__) 53 54 } // namespace Common 55 } // namespace UserIam 56 } // namespace OHOS 57 58 #endif // IAM_LOGGER_H 59