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