1ea497e4dSopenharmony_ci/*
2ea497e4dSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3ea497e4dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4ea497e4dSopenharmony_ci * you may not use this file except in compliance with the License.
5ea497e4dSopenharmony_ci * You may obtain a copy of the License at
6ea497e4dSopenharmony_ci *
7ea497e4dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8ea497e4dSopenharmony_ci *
9ea497e4dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10ea497e4dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11ea497e4dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12ea497e4dSopenharmony_ci * See the License for the specific language governing permissions and
13ea497e4dSopenharmony_ci * limitations under the License.
14ea497e4dSopenharmony_ci */
15ea497e4dSopenharmony_ci#ifndef IAM_LOGGER_H
16ea497e4dSopenharmony_ci#define IAM_LOGGER_H
17ea497e4dSopenharmony_ci
18ea497e4dSopenharmony_ci#include "hilog/log.h"
19ea497e4dSopenharmony_cinamespace OHOS {
20ea497e4dSopenharmony_cinamespace UserIam {
21ea497e4dSopenharmony_cinamespace Common {
22ea497e4dSopenharmony_ci#ifdef __FILE_NAME__
23ea497e4dSopenharmony_ci#define FACE_AUTH_LOG_FILE __FILE_NAME__
24ea497e4dSopenharmony_ci#else
25ea497e4dSopenharmony_ci#define FACE_AUTH_LOG_FILE (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
26ea497e4dSopenharmony_ci#endif
27ea497e4dSopenharmony_ci
28ea497e4dSopenharmony_ci#ifdef LOG_DOMAIN
29ea497e4dSopenharmony_ci#undef LOG_DOMAIN
30ea497e4dSopenharmony_ci#endif
31ea497e4dSopenharmony_ci
32ea497e4dSopenharmony_ci#define LOG_DOMAIN 0xD002406
33ea497e4dSopenharmony_ci
34ea497e4dSopenharmony_ci#ifdef LOG_TAG
35ea497e4dSopenharmony_ci#undef LOG_TAG
36ea497e4dSopenharmony_ci#endif
37ea497e4dSopenharmony_ci
38ea497e4dSopenharmony_ci#define FACE_DEBUG(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__)
39ea497e4dSopenharmony_ci#define FACE_INFO(...) HILOG_INFO(LOG_CORE, __VA_ARGS__)
40ea497e4dSopenharmony_ci#define FACE_WARN(...) HILOG_WARN(LOG_CORE, __VA_ARGS__)
41ea497e4dSopenharmony_ci#define FACE_ERROR(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__)
42ea497e4dSopenharmony_ci#define FACE_FATAL(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__)
43ea497e4dSopenharmony_ci
44ea497e4dSopenharmony_ci#define ARGS(fmt, ...) \
45ea497e4dSopenharmony_ci    "[%{public}s@%{public}s:%{public}d] " fmt, __FUNCTION__, FACE_AUTH_LOG_FILE, __LINE__, ##__VA_ARGS__
46ea497e4dSopenharmony_ci#define FACE_LOG(level, ...) FACE_##level(ARGS(__VA_ARGS__))
47ea497e4dSopenharmony_ci
48ea497e4dSopenharmony_ci#define IAM_LOGD(...) FACE_LOG(DEBUG, __VA_ARGS__)
49ea497e4dSopenharmony_ci#define IAM_LOGI(...) FACE_LOG(INFO, __VA_ARGS__)
50ea497e4dSopenharmony_ci#define IAM_LOGW(...) FACE_LOG(WARN, __VA_ARGS__)
51ea497e4dSopenharmony_ci#define IAM_LOGE(...) FACE_LOG(ERROR, __VA_ARGS__)
52ea497e4dSopenharmony_ci#define IAM_LOGF(...) FACE_LOG(FATAL, __VA_ARGS__)
53ea497e4dSopenharmony_ci
54ea497e4dSopenharmony_ci} // namespace Common
55ea497e4dSopenharmony_ci} // namespace UserIam
56ea497e4dSopenharmony_ci} // namespace OHOS
57ea497e4dSopenharmony_ci
58ea497e4dSopenharmony_ci#endif // IAM_LOGGER_H
59