• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef HIDUMPER_UTILS_HILOG_WRAPPER_H
16 #define HIDUMPER_UTILS_HILOG_WRAPPER_H
17 #define CONFIG_HILOG
18 #ifdef CONFIG_HILOG
19 #include "hilog/log.h"
20 namespace OHOS {
21 namespace HiviewDFX {
22 #ifdef DUMPER_HILOGF
23 #undef DUMPER_HILOGF
24 #endif
25 #ifdef DUMPER_HILOGE
26 #undef DUMPER_HILOGE
27 #endif
28 #ifdef DUMPER_HILOGW
29 #undef DUMPER_HILOGW
30 #endif
31 #ifdef DUMPER_HILOGI
32 #undef DUMPER_HILOGI
33 #endif
34 #ifdef DUMPER_HILOGD
35 #undef DUMPER_HILOGD
36 #endif
37 // param of log interface, such as DUMPER_HILOGF.
38 enum DumperSubModule {
39     MODULE_COMMON = 0,
40     MODULE_ZIDL,
41     MODULE_CLIENT,
42     MODULE_SERVICE,
43     MODULE_MAX,
44 };
45 // 0xD002900: subsystem:DumperMgr module:DumperManager, 8 bits reserved.
46 static constexpr unsigned int BASE_DUMPER_DOMAIN_ID = 0xD002900;
47 enum DumperMgrDomainId {
48     DUMPER_COMMON_DOMAIN = BASE_DUMPER_DOMAIN_ID + MODULE_COMMON,
49     DUMPER_ZIDL_DOMAIN,
50     DUMPER_CLIENT_DOMAIN,
51     DUMPER_SERVICE_DOMAIN,
52 };
53 static constexpr OHOS::HiviewDFX::HiLogLabel DUMPER_LABEL[MODULE_MAX] = {
54     {LOG_CORE, DUMPER_COMMON_DOMAIN, "DumperCommon"},
55     {LOG_CORE, DUMPER_ZIDL_DOMAIN, "DumperZIDL"},
56     {LOG_CORE, DUMPER_CLIENT_DOMAIN, "DumperClient"},
57     {LOG_CORE, DUMPER_SERVICE_DOMAIN, "DumperService"},
58 };
59 // In order to improve performance, do not check the module range.
60 // Besides, make sure module is less than DUMPER_MAX_DOMAIN.
61 #define DUMPER_HILOGF(module, fmt, ...) \
62     (void)OHOS::HiviewDFX::HiLog::Fatal(DUMPER_LABEL[module], "%{public}s# " fmt, __FUNCTION__, ##__VA_ARGS__)
63 #define DUMPER_HILOGE(module, fmt, ...) \
64     (void)OHOS::HiviewDFX::HiLog::Error(DUMPER_LABEL[module], "%{public}s# " fmt, __FUNCTION__, ##__VA_ARGS__)
65 #define DUMPER_HILOGW(module, fmt, ...) \
66     (void)OHOS::HiviewDFX::HiLog::Warn(DUMPER_LABEL[module], "%{public}s# " fmt, __FUNCTION__, ##__VA_ARGS__)
67 #define DUMPER_HILOGI(module, fmt, ...) \
68     (void)OHOS::HiviewDFX::HiLog::Info(DUMPER_LABEL[module], "%{public}s# " fmt, __FUNCTION__, ##__VA_ARGS__)
69 #define DUMPER_HILOGD(module, fmt, ...) \
70     (void)OHOS::HiviewDFX::HiLog::Debug(DUMPER_LABEL[module], "%{public}s# " fmt, __FUNCTION__, ##__VA_ARGS__)
71 } // namespace HiviewDFX
72 } // namespace OHOS
73 #else
74 #define DUMPER_HILOGF(...)
75 #define DUMPER_HILOGE(...)
76 #define DUMPER_HILOGW(...)
77 #define DUMPER_HILOGI(...)
78 #define DUMPER_HILOGD(...)
79 #endif // CONFIG_HILOG
80 #endif // HIDUMPER_UTILS_HILOG_WRAPPER_H
81