• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 USERAUTH_HILOG_WRAPPER_H
17 #define USERAUTH_HILOG_WRAPPER_H
18 
19 #define CONFIG_HILOG
20 #ifdef CONFIG_HILOG
21 #include "hilog/log.h"
22 namespace OHOS {
23 namespace UserIAM {
24 namespace UserAuth {
25 #define FILENAME            (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
26 #define FORMATED(fmt, ...)    "[%{public}s] %{public}s# " fmt, FILENAME, __FUNCTION__, ##__VA_ARGS__
27 
28 #ifdef USERAUTH_HILOGF
29 #undef USERAUTH_HILOGF
30 #endif
31 
32 #ifdef USERAUTH_HILOGE
33 #undef USERAUTH_HILOGE
34 #endif
35 
36 #ifdef USERAUTH_HILOGW
37 #undef USERAUTH_HILOGW
38 #endif
39 
40 #ifdef USERAUTH_HILOGI
41 #undef USERAUTH_HILOGI
42 #endif
43 
44 #ifdef USERAUTH_HILOGD
45 #undef USERAUTH_HILOGD
46 #endif
47 
48 enum UserAuthSubModule {
49     MODULE_INNERKIT = 0,
50     MODULE_SERVICE,
51     MODULE_COMMON,
52     MODULE_JS_NAPI,
53     USERAUTHS_MODULE_BUTT,
54 };
55 
56 static constexpr unsigned int BASE_USERAUTH_DOMAIN_ID = 0xD002910;
57 
58 enum UserAuthDomainId {
59     USERAUTH_INNERKIT_DOMAIN = BASE_USERAUTH_DOMAIN_ID + MODULE_INNERKIT,
60     USERAUTH_SERVICE_DOMAIN,
61     COMMON_DOMAIN,
62     USERAUTH_JS_NAPI
63 };
64 
65 static constexpr OHOS::HiviewDFX::HiLogLabel USERAUTH_LABEL[USERAUTHS_MODULE_BUTT] = {
66     {LOG_CORE, USERAUTH_INNERKIT_DOMAIN, "UserAuthClient"},
67     {LOG_CORE, USERAUTH_SERVICE_DOMAIN, "UserAuthService"},
68     {LOG_CORE, COMMON_DOMAIN, "UserAuthCommon"},
69     {LOG_CORE, USERAUTH_JS_NAPI, "UserAuthJSNAPI"},
70 };
71 
72 // In order to improve performance, do not check the module range.
73 // Besides, make sure module is less than USERAUTHS_MODULE_BUTT.
74 #define USERAUTH_HILOGF(module, ...) (void)OHOS::HiviewDFX::HiLog::Fatal(USERAUTH_LABEL[module], FORMATED(__VA_ARGS__))
75 #define USERAUTH_HILOGE(module, ...) (void)OHOS::HiviewDFX::HiLog::Error(USERAUTH_LABEL[module], FORMATED(__VA_ARGS__))
76 #define USERAUTH_HILOGW(module, ...) (void)OHOS::HiviewDFX::HiLog::Warn(USERAUTH_LABEL[module], FORMATED(__VA_ARGS__))
77 #define USERAUTH_HILOGI(module, ...) (void)OHOS::HiviewDFX::HiLog::Info(USERAUTH_LABEL[module], FORMATED(__VA_ARGS__))
78 #define USERAUTH_HILOGD(module, ...) (void)OHOS::HiviewDFX::HiLog::Debug(USERAUTH_LABEL[module], FORMATED(__VA_ARGS__))
79 } // namespace UserAuth
80 } // namespace UserIAM
81 } // namespace OHOS
82 
83 #else
84 
85 #define USERAUTH_HILOGF(...)
86 #define USERAUTH_HILOGE(...)
87 #define USERAUTH_HILOGW(...)
88 #define USERAUTH_HILOGI(...)
89 #define USERAUTH_HILOGD(...)
90 
91 #endif // CONFIG_HILOG
92 
93 #endif // USERAUTH_HILOG_WRAPPER_H
94