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 
17 #ifndef MOCK_NATIVE_INCLUDE_HILOG_LOG_C_H
18 #define MOCK_NATIVE_INCLUDE_HILOG_LOG_C_H
19 
20 #include <stdarg.h>
21 #include <stdbool.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 // Log domain
28 #ifndef LOG_DOMAIN
29 #define LOG_DOMAIN 0
30 #endif
31 
32 // Log tag
33 #ifndef LOG_TAG
34 #define LOG_TAG NULL
35 #endif
36 
37 // Log type
38 typedef enum {
39     LOG_TYPE_MIN = 0,
40     // Log to kmsg, only used by init phase.
41     LOG_INIT = 1,
42     // Used by core service, framework.
43     LOG_CORE = 3,
44     LOG_TYPE_MAX
45 } LogType;
46 
47 // Log level
48 typedef enum {
49     LOG_LEVEL_MIN = 0,
50     LOG_DEBUG = 3,
51     LOG_INFO = 4,
52     LOG_WARN = 5,
53     LOG_ERROR = 6,
54     LOG_FATAL = 7,
55     LOG_LEVEL_MAX,
56 } LogLevel;
57 
58 int HiLogPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...)
59     __attribute__((__format__(os_log, 5, 6)));
60 
61 #define HILOG_DEBUG(type, ...) ((void)HiLogPrint((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
62 
63 #define HILOG_INFO(type, ...) ((void)HiLogPrint((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
64 
65 #define HILOG_WARN(type, ...) ((void)HiLogPrint((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
66 
67 #define HILOG_ERROR(type, ...) ((void)HiLogPrint((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
68 
69 #define HILOG_FATAL(type, ...) ((void)HiLogPrint((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
70 
71 bool HiLogIsLoggable(unsigned int domain, const char *tag, LogLevel level);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif // MOCK_NATIVE_INCLUDE_HILOG_LOG_C_H
78