1  /*
2   * Copyright (c) 2021-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 SAMGR_PROXY_INCLUDE_SAM_LOG_H
17  #define SAMGR_PROXY_INCLUDE_SAM_LOG_H
18  
19  #include "hilog/log.h"
20  
21  namespace OHOS {
22  
23  constexpr OHOS::HiviewDFX::HiLogLabel SYSTEM_ABLILITY_LABEL = {
24      LOG_KMSG,
25      0xD001800,
26      "SAMGR"
27  };
28  
29  #undef LOG_DOMAIN
30  #ifdef SAMGR_PROXY
31  #define LOG_DOMAIN 0xD001810
32  #else
33  #define LOG_DOMAIN 0xD001800
34  #endif
35  
36  #undef LOG_TAG
37  #ifdef SAMGR_PROXY
38  #define LOG_TAG "SA_CLIENT"
39  #else
40  #define LOG_TAG "SAMGR"
41  #endif
42  
43  #ifdef HILOGF
44  #undef HILOGF
45  #endif
46  
47  #ifdef HILOGE
48  #undef HILOGE
49  #endif
50  
51  #ifdef HILOGW
52  #undef HILOGW
53  #endif
54  
55  #ifdef HILOGI
56  #undef HILOGI
57  #endif
58  
59  #ifdef HILOGD
60  #undef HILOGD
61  #endif
62  
63  #ifdef KHILOGI
64  #undef KHILOGI
65  #endif
66  
67  #ifdef KHILOGE
68  #undef KHILOGE
69  #endif
70  
71  #ifdef KHILOGW
72  #undef KHILOGW
73  #endif
74  
75  #ifdef KHILOGD
76  #undef KHILOGD
77  #endif
78  
79  #ifdef KHILOGF
80  #undef KHILOGF
81  #endif
82  
83  #define KHILOGI(...) \
84      do { \
85          (void)OHOS::HiviewDFX::HiLog::Info(SYSTEM_ABLILITY_LABEL, __VA_ARGS__); \
86          HILOG_INFO(LOG_CORE, __VA_ARGS__); \
87      } while (0)
88  
89  #define KHILOGE(...) \
90      do { \
91          (void)OHOS::HiviewDFX::HiLog::Error(SYSTEM_ABLILITY_LABEL, __VA_ARGS__); \
92          HILOG_ERROR(LOG_CORE, __VA_ARGS__); \
93      } while (0)
94  
95  #define KHILOGW(...) \
96      do { \
97          (void)OHOS::HiviewDFX::HiLog::Warn(SYSTEM_ABLILITY_LABEL, __VA_ARGS__); \
98          HILOG_WARN(LOG_CORE, __VA_ARGS__); \
99      } while (0)
100  
101  #define KHILOGD(...) \
102      do { \
103          (void)OHOS::HiviewDFX::HiLog::Debug(SYSTEM_ABLILITY_LABEL, __VA_ARGS__); \
104          HILOG_DEBUG(LOG_CORE, __VA_ARGS__); \
105      } while (0)
106  
107  #define KHILOGF(...) \
108      do { \
109          (void)OHOS::HiviewDFX::HiLog::Fatal(SYSTEM_ABLILITY_LABEL, __VA_ARGS__); \
110          HILOG_FATAL(LOG_CORE, __VA_ARGS__); \
111      } while (0)
112  
113  #define HILOGF(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__)
114  #define HILOGE(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__)
115  #define HILOGW(...) HILOG_WARN(LOG_CORE, __VA_ARGS__)
116  #define HILOGI(...) HILOG_INFO(LOG_CORE, __VA_ARGS__)
117  #define HILOGD(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__)
118  } // namespace OHOS
119  
120  #endif // #ifndef SAMGR_PROXY_INCLUDE_SAM_LOG_H
121