• 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 
16 #ifndef HILOG_WRAPPER_H
17 #define HILOG_WRAPPER_H
18 
19 #ifdef CONFIG_HILOG
20 
21 #include "hilog/log.h"
22 
23 #ifdef HILOG_FATAL
24 #undef HILOG_FATAL
25 #endif
26 
27 #ifdef HILOG_ERROR
28 #undef HILOG_ERROR
29 #endif
30 
31 #ifdef HILOG_WARN
32 #undef HILOG_WARN
33 #endif
34 
35 #ifdef HILOG_INFO
36 #undef HILOG_INFO
37 #endif
38 
39 #ifdef HILOG_DEBUG
40 #undef HILOG_DEBUG
41 #endif
42 
43 namespace OHOS {
44 namespace Global {
45 namespace Resource {
46 extern LogLevel g_logLevel;
47 } // namespace Resource
48 } // namespace Global
49 } // namespace OHOS
50 
51 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, 0xD001E00, "ResourceManager"};
52 
53 #define HILOG_FATAL(...) (void)OHOS::HiviewDFX::HiLog::Fatal(LOG_LABEL, __VA_ARGS__)
54 #define HILOG_ERROR(...) (void)OHOS::HiviewDFX::HiLog::Error(LOG_LABEL, __VA_ARGS__)
55 #define HILOG_WARN(...) {                                            \
56 if (OHOS::Global::Resource::g_logLevel <= LOG_WARN) {                \
57     (void)OHOS::HiviewDFX::HiLog::Warn(LOG_LABEL, __VA_ARGS__);      \
58 }                                                                    \
59 }
60 
61 #define HILOG_INFO(...) {                                            \
62 if (OHOS::Global::Resource::g_logLevel <= LOG_INFO) {                \
63     (void)OHOS::HiviewDFX::HiLog::Info(LOG_LABEL, __VA_ARGS__);      \
64 }                                                                    \
65 }
66 
67 #define HILOG_DEBUG(...) {                                           \
68 if (OHOS::Global::Resource::g_logLevel <= LOG_DEBUG) {               \
69     (void)OHOS::HiviewDFX::HiLog::Debug(LOG_LABEL, __VA_ARGS__);     \
70 }                                                                    \
71 }
72 
73 #else
74 
75 #define HILOG_FATAL(...)
76 #define HILOG_ERROR(...)
77 #define HILOG_WARN(...)
78 #define HILOG_INFO(...)
79 #define HILOG_DEBUG(...)
80 #endif  // CONFIG_HILOG
81 
82 #endif  // HILOG_WRAPPER_H