• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 POWERMGR_HILOG_WRAPPER_H
17 #define POWERMGR_HILOG_WRAPPER_H
18 
19 #define LOG_TAG                 "BatteryMgr"
20 
21 #include <log.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif // __cplusplus
26 
27 #define FILE_NAME            (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
28 #define FILE_FORMATED(fmt, ...)  "[%s] %s# " fmt, FILE_NAME, __FUNCTION__, ##__VA_ARGS__
29 
30 #ifdef POWER_HILOGD
31 #undef POWER_HILOGD
32 #endif
33 
34 #ifdef POWER_HILOGI
35 #undef POWER_HILOGI
36 #endif
37 
38 #ifdef POWER_HILOGW
39 #undef POWER_HILOGW
40 #endif
41 
42 #ifdef POWER_HILOGE
43 #undef POWER_HILOGE
44 #endif
45 
46 #ifdef POWER_HILOGF
47 #undef POWER_HILOGF
48 #endif
49 
50 #ifdef __LITEOS_M__
51 #define POWER_HILOGD(...)   HILOG_DEBUG(HILOG_MODULE_POWERMGR, __VA_ARGS__)
52 #define POWER_HILOGI(...)   HILOG_INFO(HILOG_MODULE_POWERMGR, __VA_ARGS__)
53 #define POWER_HILOGW(...)   HILOG_WARN(HILOG_MODULE_POWERMGR, __VA_ARGS__)
54 #define POWER_HILOGE(...)   HILOG_ERROR(HILOG_MODULE_POWERMGR, __VA_ARGS__)
55 #define POWER_HILOGF(...)   HILOG_FATAL(HILOG_MODULE_POWERMGR, __VA_ARGS__)
56 #else // !__LITEOS_M__
57 #define POWER_HILOGD(...)   HILOG_DEBUG(LOG_CORE, FILE_FORMATED(__VA_ARGS__))
58 #define POWER_HILOGI(...)   HILOG_INFO(LOG_CORE, FILE_FORMATED(__VA_ARGS__))
59 #define POWER_HILOGW(...)   HILOG_WARN(LOG_CORE, FILE_FORMATED(__VA_ARGS__))
60 #define POWER_HILOGE(...)   HILOG_ERROR(LOG_CORE, FILE_FORMATED(__VA_ARGS__))
61 #define POWER_HILOGF(...)   HILOG_FATAL(LOG_CORE, FILE_FORMATED(__VA_ARGS__))
62 #endif // __LITEOS_M__
63 
64 #ifdef __cplusplus
65 }
66 #endif // __cplusplus
67 #endif // POWERMGR_HILOG_WRAPPER_H
68