blob: fd451853ae54c5fa304e550e3345ad9ea040fda8 [file] [log] [blame]
b.liu4e243dc2023-11-27 11:20:00 +08001#ifndef __LYNQ_DEFLOG_H__
2#define __LYNQ_DEFLOG_H__
3#include "liblog.h"
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9typedef void (*LYNQ_WRITE_LOG_PTR)(log_level_enum level, const char *format, ...);
10extern LYNQ_WRITE_LOG_PTR lynq_write_log;
11LYNQ_WRITE_LOG_PTR lynq_log_function_init(const char *log_name);
12
13int lynq_syslog_set_file_size(int value);
14int lynq_syslog_get_file_size(void);
15int lynq_syslog_set_file_rotate(int value);
16int lynq_syslog_get_file_rotate(void);
17
18#ifdef __cplusplus
19}
20#endif
xf.li43643772024-03-04 19:39:53 -080021#define lynq_log_verbose(fmt, args...) \
22 do{ \
23 char *file_ptr_1001 = __FILE__; \
24 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
25 char line_1001[10] = {0}; \
26 sprintf(line_1001, "%d", __LINE__); \
27 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
28 if(*ptr_1001 == '/') \
29 break; \
30 ptr_1001--; \
31 } \
32 mbtk_log(LOG_VERBOSE_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
33 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +080034
xf.li43643772024-03-04 19:39:53 -080035#define lynq_log_error(fmt, args...) \
36 do{ \
37 char *file_ptr_1001 = __FILE__; \
38 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
39 char line_1001[10] = {0}; \
40 sprintf(line_1001, "%d", __LINE__); \
41 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
42 if(*ptr_1001 == '/') \
43 break; \
44 ptr_1001--; \
45 } \
46 mbtk_log(LOG_ERR_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
47 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +080048
xf.li43643772024-03-04 19:39:53 -080049#define lynq_log_warning(fmt, args...) \
50 do{ \
51 char *file_ptr_1001 = __FILE__; \
52 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
53 char line_1001[10] = {0}; \
54 sprintf(line_1001, "%d", __LINE__); \
55 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
56 if(*ptr_1001 == '/') \
57 break; \
58 ptr_1001--; \
59 } \
60 mbtk_log(LOG_WARN_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
61 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +080062
xf.li43643772024-03-04 19:39:53 -080063#define lynq_log_info(fmt, args...) \
64 do{ \
65 char *file_ptr_1001 = __FILE__; \
66 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
67 char line_1001[10] = {0}; \
68 sprintf(line_1001, "%d", __LINE__); \
69 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
70 if(*ptr_1001 == '/') \
71 break; \
72 ptr_1001--; \
73 } \
74 mbtk_log(LOG_INFO_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
75 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +080076
xf.li43643772024-03-04 19:39:53 -080077#define lynq_log_debug(fmt, args...) \
78 do{ \
79 char *file_ptr_1001 = __FILE__; \
80 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
81 char line_1001[10] = {0}; \
82 sprintf(line_1001, "%d", __LINE__); \
83 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
84 if(*ptr_1001 == '/') \
85 break; \
86 ptr_1001--; \
87 } \
88 mbtk_log(LOG_DEBUG_LEVEL, "%s#%s: " fmt "\n", ptr_1001 + 1, line_1001, ##args); \
89 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +080090
xf.li43643772024-03-04 19:39:53 -080091#define LYVERBLOG(fmt, args...) \
92 do{ \
93 char *file_ptr_1001 = __FILE__; \
94 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
95 char line_1001[10] = {0}; \
96 sprintf(line_1001, "%d", __LINE__); \
97 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
98 if(*ptr_1001 == '/') \
99 break; \
100 ptr_1001--; \
101 } \
102 mbtk_log(LOG_VERBOSE_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
103 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +0800104
xf.li43643772024-03-04 19:39:53 -0800105#define LYERRLOG(fmt, args...) \
106 do{ \
107 char *file_ptr_1001 = __FILE__; \
108 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
109 char line_1001[10] = {0}; \
110 sprintf(line_1001, "%d", __LINE__); \
111 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
112 if(*ptr_1001 == '/') \
113 break; \
114 ptr_1001--; \
115 } \
116 mbtk_log(LOG_ERR_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
117 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +0800118
xf.li43643772024-03-04 19:39:53 -0800119#define LYWARNLOG(fmt, args...) \
120 do{ \
121 char *file_ptr_1001 = __FILE__; \
122 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
123 char line_1001[10] = {0}; \
124 sprintf(line_1001, "%d", __LINE__); \
125 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
126 if(*ptr_1001 == '/') \
127 break; \
128 ptr_1001--; \
129 } \
130 mbtk_log(LOG_WARN_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
131 } while(0)
b.liu4e243dc2023-11-27 11:20:00 +0800132
xf.li43643772024-03-04 19:39:53 -0800133#define LYINFLOG(fmt, args...) \
134 do{ \
135 char *file_ptr_1001 = __FILE__; \
136 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
137 char line_1001[10] = {0}; \
138 sprintf(line_1001, "%d", __LINE__); \
139 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
140 if(*ptr_1001 == '/') \
141 break; \
142 ptr_1001--; \
143 } \
144 mbtk_log(LOG_INFO_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
145 } while(0)
146
147#define LYDBGLOG(fmt, args...) \
148 do{ \
149 char *file_ptr_1001 = __FILE__; \
150 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
151 char line_1001[10] = {0}; \
152 sprintf(line_1001, "%d", __LINE__); \
153 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
154 if(*ptr_1001 == '/') \
155 break; \
156 ptr_1001--; \
157 } \
158 mbtk_log(LOG_DEBUG_LEVEL, "%s#%s: " fmt "\n", ptr_1001 + 1, line_1001, ##args); \
159 } while(0)
160// #define lynq_log_verbose(...) do { lynq_write_log(LOG_VERBOSE,__VA_ARGS__);} while (0)
161// #define lynq_log_error(...) do {lynq_write_log(LOG_ERROR,__VA_ARGS__);} while (0)
162// #define lynq_log_warning(...) do {lynq_write_log(LOG_WARNING,__VA_ARGS__);} while (0)
163// #define lynq_log_info(...) do {lynq_write_log(LOG_INFO,__VA_ARGS__);} while (0)
164// #define lynq_log_debug(...) do {lynq_write_log(LOG_DEBUG,__VA_ARGS__);} while (0)
165
166// #define LYVERBLOG(...) do {lynq_write_log(LOG_VERBOSE,__VA_ARGS__);} while (0)
167// #define LYERRLOG(...) do {lynq_write_log(LOG_ERROR,__VA_ARGS__);} while (0)
168// #define LYWARNLOG(...) do {lynq_write_log(LOG_WARNING,__VA_ARGS__);} while(0)
169// #define LYINFLOG(...) do {lynq_write_log(LOG_INFO,__VA_ARGS__);} while (0)
170// #define LYDBGLOG(...) do {lynq_write_log(LOG_DEBUG,__VA_ARGS__);} while (0)
171
172// // just for comcompatibility, do nothing
173// #define LYLOGSET(a) do{;}while(0)
174// #define LYLOGEINIT(Y) do{;}while(0)
175
176// #ifndef ALOGV
177// #define ALOGV(...) do {lynq_write_log(LOG_VERBOSE,__VA_ARGS__);} while (0)
178// #endif
179
180// #ifndef ALOGE
181// #define ALOGE(...) do {lynq_write_log(LOG_ERROR,__VA_ARGS__);} while (0)
182// #endif
183
184// #ifndef ALOGW
185// #define ALOGW(...) do {lynq_write_log(LOG_WARNING,__VA_ARGS__);} while (0)
186// #endif
187
188// #ifndef ALOGI
189// #define ALOGI(...) do {lynq_write_log(LOG_INFO,__VA_ARGS__);} while (0)
190// #endif
191
192// #ifndef ALOGD
193// #define ALOGD(...) do {lynq_write_log(LOG_DEBUG,__VA_ARGS__);} while (0)
194// #endif
b.liu4e243dc2023-11-27 11:20:00 +0800195
196#define DEFINE_LYNQ_LIB_LOG(tag) \
197 LYNQ_WRITE_LOG_PTR __attribute__ ((visibility ("hidden"))) lynq_write_log = NULL; \
198 void __attribute__((constructor)) tag##_init() \
199 { \
200 lynq_write_log = lynq_log_function_init(#tag); \
201 }
202
203#define DEFINE_LYNQ_EXE_LOG(tag) \
204 LYNQ_WRITE_LOG_PTR __attribute__ ((visibility ("hidden"))) lynq_write_log = NULL; \
205 void __attribute__((constructor)) tag##_init() \
206 { \
207 lynq_write_log = lynq_log_function_init(#tag); \
208 lynq_log_configuration_init(#tag); \
209 }
210
211#endif //__LYNQ_DEFLOG_H__