/src/libwebsockets/include/libwebsockets/lws-logs.h
Line | Count | Source |
1 | | /* |
2 | | * libwebsockets - small server side websockets and web server implementation |
3 | | * |
4 | | * Copyright (C) 2010 - 2021 Andy Green <andy@warmcat.com> |
5 | | * |
6 | | * Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | | * of this software and associated documentation files (the "Software"), to |
8 | | * deal in the Software without restriction, including without limitation the |
9 | | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | | * sell copies of the Software, and to permit persons to whom the Software is |
11 | | * furnished to do so, subject to the following conditions: |
12 | | * |
13 | | * The above copyright notice and this permission notice shall be included in |
14 | | * all copies or substantial portions of the Software. |
15 | | * |
16 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
20 | | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
21 | | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
22 | | * IN THE SOFTWARE. |
23 | | */ |
24 | | |
25 | | /** \defgroup log Logging |
26 | | * |
27 | | * ##Logging |
28 | | * |
29 | | * Lws provides flexible and filterable logging facilities, which can be |
30 | | * used inside lws and in user code. |
31 | | * |
32 | | * Log categories may be individually filtered bitwise, and directed to built-in |
33 | | * sinks for syslog-compatible logging, or a user-defined function. |
34 | | * |
35 | | * Traditional logs use a single, processwide logging context. New style log |
36 | | * apis (lws_xxx_cx()) can pass the logging context to use in. |
37 | | */ |
38 | | ///@{ |
39 | | |
40 | 116 | #define LLL_ERR (1 << 0) |
41 | 0 | #define LLL_WARN (1 << 1) |
42 | 0 | #define LLL_NOTICE (1 << 2) |
43 | 0 | #define LLL_INFO (1 << 3) |
44 | 11.0k | #define LLL_DEBUG (1 << 4) |
45 | 0 | #define LLL_PARSER (1 << 5) |
46 | 0 | #define LLL_HEADER (1 << 6) |
47 | | #define LLL_EXT (1 << 7) |
48 | 0 | #define LLL_CLIENT (1 << 8) |
49 | | #define LLL_LATENCY (1 << 9) |
50 | 0 | #define LLL_USER (1 << 10) |
51 | | #define LLL_THREAD (1 << 11) |
52 | | |
53 | 116 | #define LLL_COUNT (12) /* set to count of valid flags */ |
54 | | |
55 | | #define LLLF_SECRECY_PII (1 << 16) |
56 | | /**< contains Personally Identifiable Information */ |
57 | | #define LLLF_SECRECY_BEARER (1 << 17) |
58 | | /**< possession of this data allows impersonation */ |
59 | | |
60 | | #define LLLF_LOG_TIMESTAMP (1 << 18) |
61 | | /**< set to prepend logs with timestamp */ |
62 | | |
63 | 77 | #define LLLF_LOG_CONTEXT_AWARE (1 << 30) |
64 | | /**< set if the context uses an emit function that takes the logctx, auto- |
65 | | * applied when setting emit using lws_set_log_level_cx() api */ |
66 | | |
67 | | struct lws_log_cx; |
68 | | |
69 | | typedef void (*lws_log_emit_t)(int level, const char *line); |
70 | | typedef void (*lws_log_emit_cx_t)(struct lws_log_cx *cx, int level, |
71 | | const char *line, size_t len); |
72 | | typedef void (*lws_log_prepend_cx_t)(struct lws_log_cx *cx, void *obj, |
73 | | char **p, char *e); |
74 | | typedef void (*lws_log_use_cx_t)(struct lws_log_cx *cx, int _new); |
75 | | |
76 | | /* |
77 | | * This is the logging context |
78 | | */ |
79 | | |
80 | | typedef struct lws_log_cx { |
81 | | union { |
82 | | /* Apparently Qt likes to leave 'emit' defined at the preprocessor */ |
83 | | #if defined(emit) |
84 | | #undef emit |
85 | | #endif |
86 | | lws_log_emit_t emit; /* legacy emit function */ |
87 | | lws_log_emit_cx_t emit_cx; /* LLLF_LOG_CONTEXT_AWARE */ |
88 | | } u; |
89 | | |
90 | | #if LWS_MAX_SMP > 1 |
91 | | pthread_mutex_t refcount_lock; |
92 | | #endif |
93 | | |
94 | | lws_log_use_cx_t refcount_cb; |
95 | | /**< NULL, or a function called after each change to .refcount below, |
96 | | * this enables implementing side-effects like opening and closing |
97 | | * log files when the first and last object binds / unbinds */ |
98 | | lws_log_prepend_cx_t prepend; |
99 | | /**< NULL, or a cb to optionally prepend a string to logs we are a |
100 | | * parent of */ |
101 | | struct lws_log_cx *parent; |
102 | | /**< NULL, or points to log ctx we are a child of */ |
103 | | void *opaque; |
104 | | /**< ignored by lws, used to pass config to emit_cx, eg, filepath */ |
105 | | void *stg; |
106 | | /**< ignored by lws, may be used a storage by refcount_cb / emit_cx */ |
107 | | uint32_t lll_flags; |
108 | | /**< mask of log levels we want to emit in this context */ |
109 | | int32_t refcount; |
110 | | /**< refcount of objects bound to this log context */ |
111 | | #if LWS_MAX_SMP > 1 |
112 | | char inited; |
113 | | #endif |
114 | | } lws_log_cx_t; |
115 | | |
116 | | /** |
117 | | * lwsl_timestamp: generate logging timestamp string |
118 | | * |
119 | | * \param level: logging level |
120 | | * \param p: char * buffer to take timestamp |
121 | | * \param len: length of p |
122 | | * |
123 | | * returns length written in p |
124 | | */ |
125 | | LWS_VISIBLE LWS_EXTERN int |
126 | | lwsl_timestamp(int level, char *p, size_t len); |
127 | | |
128 | | typedef struct lws_log_ratelimit { |
129 | | int64_t next_log_us; |
130 | | uint32_t dropped; |
131 | | } lws_log_ratelimit_t; |
132 | | |
133 | | #define LWS_RATELIMIT_DEFINE_STATIC(_name) \ |
134 | | static lws_log_ratelimit_t _name = { 0, 0 } |
135 | | |
136 | | LWS_VISIBLE LWS_EXTERN uint32_t |
137 | | lws_log_ratelimit_check(lws_log_ratelimit_t *rl, int64_t interval_us); |
138 | | |
139 | | LWS_VISIBLE LWS_EXTERN void |
140 | | _lws_log_rl(int filter, uint32_t dropped, const char *format, ...) LWS_FORMAT(3); |
141 | | |
142 | | LWS_VISIBLE LWS_EXTERN void |
143 | | _lws_log_cx_rl(lws_log_cx_t *cx, lws_log_prepend_cx_t prep, void *obj, |
144 | | int filter, uint32_t dropped, const char *_fun, const char *format, ...) LWS_FORMAT(7); |
145 | | |
146 | | #if defined(LWS_PLAT_OPTEE) && !defined(LWS_WITH_NETWORK) |
147 | | #define _lws_log(aaa, ...) SMSG(__VA_ARGS__) |
148 | | #else |
149 | | LWS_VISIBLE LWS_EXTERN void |
150 | | _lws_log(int filter, const char *format, ...) LWS_FORMAT(2); |
151 | | LWS_VISIBLE LWS_EXTERN void |
152 | | _lws_logv(int filter, const char *format, va_list vl); |
153 | | #endif |
154 | | |
155 | | struct lws_vhost; |
156 | | struct lws; |
157 | | |
158 | | LWS_VISIBLE LWS_EXTERN struct lws_log_cx * |
159 | | lwsl_context_get_cx(struct lws_context *cx); |
160 | | LWS_VISIBLE LWS_EXTERN struct lws_log_cx * |
161 | | lwsl_vhost_get_cx(struct lws_vhost *vh); |
162 | | LWS_VISIBLE LWS_EXTERN struct lws_log_cx * |
163 | | lwsl_wsi_get_cx(struct lws *wsi); |
164 | | #if defined(LWS_WITH_SECURE_STREAMS) |
165 | | struct lws_ss_handle; |
166 | | LWS_VISIBLE LWS_EXTERN struct lws_log_cx * |
167 | | lwsl_ss_get_cx(struct lws_ss_handle *ss); |
168 | | #endif |
169 | | #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API) |
170 | | struct lws_sspc_handle; |
171 | | LWS_VISIBLE LWS_EXTERN struct lws_log_cx * |
172 | | lwsl_sspc_get_cx(struct lws_sspc_handle *ss); |
173 | | #endif |
174 | | |
175 | | |
176 | | LWS_VISIBLE LWS_EXTERN void |
177 | | lws_log_emit_cx_file(struct lws_log_cx *cx, int level, const char *line, |
178 | | size_t len); |
179 | | |
180 | | LWS_VISIBLE LWS_EXTERN void |
181 | | lws_log_use_cx_file(struct lws_log_cx *cx, int _new); |
182 | | |
183 | | LWS_VISIBLE LWS_EXTERN void |
184 | | lws_log_prepend_context(struct lws_log_cx *cx, void *obj, char **p, char *e); |
185 | | LWS_VISIBLE LWS_EXTERN void |
186 | | lws_log_prepend_vhost(struct lws_log_cx *cx, void *obj, char **p, char *e); |
187 | | LWS_VISIBLE LWS_EXTERN void |
188 | | lws_log_prepend_wsi(struct lws_log_cx *cx, void *obj, char **p, char *e); |
189 | | #if defined(LWS_WITH_SECURE_STREAMS) |
190 | | LWS_VISIBLE LWS_EXTERN void |
191 | | lws_log_prepend_ss(struct lws_log_cx *cx, void *obj, char **p, char *e); |
192 | | #endif |
193 | | #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API) |
194 | | LWS_VISIBLE LWS_EXTERN void |
195 | | lws_log_prepend_sspc(struct lws_log_cx *cx, void *obj, char **p, char *e); |
196 | | #endif |
197 | | |
198 | | LWS_VISIBLE LWS_EXTERN void |
199 | | _lws_log_cx(lws_log_cx_t *cx, lws_log_prepend_cx_t prep, void *obj, |
200 | | int filter, const char *_fun, const char *format, ...) LWS_FORMAT(6); |
201 | | |
202 | | #define lwsl_cx(_c, _fil, ...) \ |
203 | 0 | _lws_log_cx(lwsl_context_get_cx(_c), lws_log_prepend_context, \ |
204 | 0 | _c, _fil, __func__, __VA_ARGS__) |
205 | | #define lwsl_vhost(_v, _fil, ...) \ |
206 | 0 | _lws_log_cx(lwsl_vhost_get_cx(_v), lws_log_prepend_vhost, _v, \ |
207 | 0 | _fil, __func__, __VA_ARGS__) |
208 | | #define lwsl_wsi(_w, _fil, ...) \ |
209 | 0 | _lws_log_cx(lwsl_wsi_get_cx(_w), lws_log_prepend_wsi, _w, \ |
210 | 0 | _fil, __func__, __VA_ARGS__) |
211 | | #define lwsl_ss(_h, _fil, ...) \ |
212 | 0 | _lws_log_cx(lwsl_ss_get_cx(_h), lws_log_prepend_ss, _h, \ |
213 | 0 | _fil, __func__, __VA_ARGS__) |
214 | | |
215 | | #define lwsl_hexdump_context(_c, _fil, _buf, _len) \ |
216 | | lwsl_hexdump_level_cx(lwsl_context_get_cx(_c), \ |
217 | | lws_log_prepend_context, \ |
218 | | _c, _fil, _buf, _len) |
219 | | #define lwsl_hexdump_vhost(_v, _fil, _buf, _len) \ |
220 | | lwsl_hexdump_level_cx(lwsl_vhost_get_cx(_v), \ |
221 | | lws_log_prepend_vhost, \ |
222 | | _v, _fil, _buf, _len) |
223 | | #define lwsl_hexdump_wsi(_w, _fil, _buf, _len) \ |
224 | 0 | lwsl_hexdump_level_cx(lwsl_wsi_get_cx(_w), \ |
225 | 0 | lws_log_prepend_wsi, \ |
226 | 0 | _w, _fil, _buf, _len) |
227 | | #define lwsl_hexdump_ss(_h, _fil, _buf, _len) \ |
228 | | lwsl_hexdump_level_cx(lwsl_ss_get_cx(_h), \ |
229 | | lws_log_prepend_ss, \ |
230 | | _h, _fil, _buf, _len) |
231 | | |
232 | | /* |
233 | | * Figure out which logs to build in or not |
234 | | */ |
235 | | |
236 | | #if defined(_DEBUG) |
237 | | /* |
238 | | * In DEBUG build, select all logs unless NO_LOGS |
239 | | */ |
240 | | #if defined(LWS_WITH_NO_LOGS) |
241 | | #define _LWS_LINIT (LLL_ERR | LLL_USER) |
242 | | #else |
243 | | #define _LWS_LINIT ((1 << LLL_COUNT) - 1) |
244 | | #endif |
245 | | #else /* not _DEBUG */ |
246 | | #if defined(LWS_WITH_NO_LOGS) |
247 | | #define _LWS_LINIT (LLL_ERR | LLL_USER) |
248 | | #else |
249 | | #define _LWS_LINIT (LLL_ERR | LLL_USER | LLL_WARN | LLL_NOTICE) |
250 | | #endif |
251 | | #endif /* _DEBUG */ |
252 | | |
253 | | /* |
254 | | * Create either empty overrides or the ones forced at build-time. |
255 | | * These overrides have the final say... any bits set in |
256 | | * LWS_LOGGING_BITFIELD_SET force the build of those logs, any bits |
257 | | * set in LWS_LOGGING_BITFIELD_CLEAR disable the build of those logs. |
258 | | * |
259 | | * If not defined lws decides based on CMAKE_BUILD_TYPE=DEBUG or not |
260 | | */ |
261 | | |
262 | | #if defined(LWS_LOGGING_BITFIELD_SET) |
263 | | #define _LWS_LBS (LWS_LOGGING_BITFIELD_SET) |
264 | | #else |
265 | | #define _LWS_LBS 0 |
266 | | #endif |
267 | | |
268 | | #if defined(LWS_LOGGING_BITFIELD_CLEAR) |
269 | | #define _LWS_LBC (LWS_LOGGING_BITFIELD_CLEAR) |
270 | | #else |
271 | | #define _LWS_LBC 0 |
272 | | #endif |
273 | | |
274 | | /* |
275 | | * Compute the final active logging bitfield for build |
276 | | */ |
277 | | #define _LWS_ENABLED_LOGS (((_LWS_LINIT) | (_LWS_LBS)) & ~(_LWS_LBC)) |
278 | | |
279 | | /* |
280 | | * Individually enable or disable log levels for build |
281 | | * depending on what was computed |
282 | | */ |
283 | | |
284 | | /* |
285 | | * Process scope logs |
286 | | */ |
287 | | |
288 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
289 | 116 | #define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__) |
290 | | #else |
291 | | #define lwsl_err(...) do {} while(0) |
292 | | #endif |
293 | | |
294 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
295 | 0 | #define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__) |
296 | | #else |
297 | | #define lwsl_warn(...) do {} while(0) |
298 | | #endif |
299 | | |
300 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
301 | 0 | #define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__) |
302 | | #else |
303 | | #define lwsl_notice(...) do {} while(0) |
304 | | #endif |
305 | | |
306 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
307 | 0 | #define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__) |
308 | | #else |
309 | | #define lwsl_info(...) do {} while(0) |
310 | | #endif |
311 | | |
312 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
313 | 11.0k | #define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__) |
314 | | #else |
315 | | #define lwsl_debug(...) do {} while(0) |
316 | | #endif |
317 | | |
318 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
319 | 0 | #define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__) |
320 | | #else |
321 | | #define lwsl_parser(...) do {} while(0) |
322 | | #endif |
323 | | |
324 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
325 | 0 | #define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__) |
326 | | #else |
327 | | #define lwsl_header(...) do {} while(0) |
328 | | #endif |
329 | | |
330 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
331 | | #define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__) |
332 | | #else |
333 | | #define lwsl_ext(...) do {} while(0) |
334 | | #endif |
335 | | |
336 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
337 | 0 | #define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__) |
338 | | #else |
339 | | #define lwsl_client(...) do {} while(0) |
340 | | #endif |
341 | | |
342 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
343 | | #define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__) |
344 | | #else |
345 | | #define lwsl_latency(...) do {} while(0) |
346 | | #endif |
347 | | |
348 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
349 | | #define lwsl_thread(...) _lws_log(LLL_THREAD, __VA_ARGS__) |
350 | | #else |
351 | | #define lwsl_thread(...) do {} while(0) |
352 | | #endif |
353 | | |
354 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
355 | 0 | #define lwsl_user(...) _lws_log(LLL_USER, __VA_ARGS__) |
356 | | #else |
357 | | #define lwsl_user(...) do {} while(0) |
358 | | #endif |
359 | | |
360 | | #define lwsl_hexdump_user(...) lwsl_hexdump_level(LLL_USER, __VA_ARGS__) |
361 | 0 | #define lwsl_hexdump_err(...) lwsl_hexdump_level(LLL_ERR, __VA_ARGS__) |
362 | | #define lwsl_hexdump_warn(...) lwsl_hexdump_level(LLL_WARN, __VA_ARGS__) |
363 | 0 | #define lwsl_hexdump_notice(...) lwsl_hexdump_level(LLL_NOTICE, __VA_ARGS__) |
364 | 0 | #define lwsl_hexdump_info(...) lwsl_hexdump_level(LLL_INFO, __VA_ARGS__) |
365 | 0 | #define lwsl_hexdump_debug(...) lwsl_hexdump_level(LLL_DEBUG, __VA_ARGS__) |
366 | | |
367 | | /* |
368 | | * lws_context scope logs |
369 | | */ |
370 | | |
371 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
372 | 0 | #define lwsl_cx_err(_c, ...) lwsl_cx(_c, LLL_ERR, __VA_ARGS__) |
373 | | #else |
374 | | #define lwsl_cx_err(_c, ...) do {} while(0) |
375 | | #endif |
376 | | |
377 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
378 | 0 | #define lwsl_cx_warn(_c, ...) lwsl_cx(_c, LLL_WARN, __VA_ARGS__) |
379 | | #else |
380 | | #define lwsl_cx_warn(_c, ...) do {} while(0) |
381 | | #endif |
382 | | |
383 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
384 | 0 | #define lwsl_cx_notice(_c, ...) lwsl_cx(_c, LLL_NOTICE, __VA_ARGS__) |
385 | | #else |
386 | | #define lwsl_cx_notice(_c, ...) do {} while(0) |
387 | | #endif |
388 | | |
389 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
390 | 0 | #define lwsl_cx_info(_c, ...) lwsl_cx(_c, LLL_INFO, __VA_ARGS__) |
391 | | #else |
392 | | #define lwsl_cx_info(_c, ...) do {} while(0) |
393 | | #endif |
394 | | |
395 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
396 | 0 | #define lwsl_cx_debug(_c, ...) lwsl_cx(_c, LLL_DEBUG, __VA_ARGS__) |
397 | | #else |
398 | | #define lwsl_cx_debug(_c, ...) do {} while(0) |
399 | | #endif |
400 | | |
401 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
402 | | #define lwsl_cx_parser(_c, ...) lwsl_cx(_c, LLL_PARSER, __VA_ARGS__) |
403 | | #else |
404 | | #define lwsl_cx_parser(_c, ...) do {} while(0) |
405 | | #endif |
406 | | |
407 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
408 | | #define lwsl_cx_header(_c, ...) lwsl_cx(_c, LLL_HEADER, __VA_ARGS__) |
409 | | #else |
410 | | #define lwsl_cx_header(_c, ...) do {} while(0) |
411 | | #endif |
412 | | |
413 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
414 | | #define lwsl_cx_ext(_c, ...) lwsl_cx(_c, LLL_EXT, __VA_ARGS__) |
415 | | #else |
416 | | #define lwsl_cx_ext(_c, ...) do {} while(0) |
417 | | #endif |
418 | | |
419 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
420 | | #define lwsl_cx_client(_c, ...) lwsl_cx(_c, LLL_CLIENT, __VA_ARGS__) |
421 | | #else |
422 | | #define lwsl_cx_client(_c, ...) do {} while(0) |
423 | | #endif |
424 | | |
425 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
426 | | #define lwsl_cx_latency(_c, ...) lwsl_cx(_c, LLL_LATENCY, __VA_ARGS__) |
427 | | #else |
428 | | #define lwsl_cx_latency(_c, ...) do {} while(0) |
429 | | #endif |
430 | | |
431 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
432 | | #define lwsl_cx_thread(_c, ...) lwsl_cx(_c, LLL_THREAD, __VA_ARGS__) |
433 | | #else |
434 | | #define lwsl_cx_thread(_c, ...) do {} while(0) |
435 | | #endif |
436 | | |
437 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
438 | | #define lwsl_cx_user(_c, ...) lwsl_cx(_c, LLL_USER, __VA_ARGS__) |
439 | | #else |
440 | | #define lwsl_cx_user(_c, ...) do {} while(0) |
441 | | #endif |
442 | | |
443 | | #define lwsl_hexdump_cx_err(_c, ...) lwsl_hexdump_context(_c, LLL_ERR, __VA_ARGS__) |
444 | | #define lwsl_hexdump_cx_warn(_c, ...) lwsl_hexdump_context(_c, LLL_WARN, __VA_ARGS__) |
445 | | #define lwsl_hexdump_cx_notice(_c, ...) lwsl_hexdump_context(_c, LLL_NOTICE, __VA_ARGS__) |
446 | | #define lwsl_hexdump_cx_info(_c, ...) lwsl_hexdump_context(_c, LLL_INFO, __VA_ARGS__) |
447 | | #define lwsl_hexdump_cx_debug(_c, ...) lwsl_hexdump_context(_c, LLL_DEBUG, __VA_ARGS__) |
448 | | |
449 | | /* |
450 | | * lws_vhost |
451 | | */ |
452 | | |
453 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
454 | 0 | #define lwsl_vhost_err(_v, ...) lwsl_vhost(_v, LLL_ERR, __VA_ARGS__) |
455 | | #else |
456 | | #define lwsl_vhost_err(_v, ...) do {} while(0) |
457 | | #endif |
458 | | |
459 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
460 | 0 | #define lwsl_vhost_warn(_v, ...) lwsl_vhost(_v, LLL_WARN, __VA_ARGS__) |
461 | | #else |
462 | | #define lwsl_vhost_warn(_v, ...) do {} while(0) |
463 | | #endif |
464 | | |
465 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
466 | 0 | #define lwsl_vhost_notice(_v, ...) lwsl_vhost(_v, LLL_NOTICE, __VA_ARGS__) |
467 | | #else |
468 | | #define lwsl_vhost_notice(_v, ...) do {} while(0) |
469 | | #endif |
470 | | |
471 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
472 | 0 | #define lwsl_vhost_info(_v, ...) lwsl_vhost(_v, LLL_INFO, __VA_ARGS__) |
473 | | #else |
474 | | #define lwsl_vhost_info(_v, ...) do {} while(0) |
475 | | #endif |
476 | | |
477 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
478 | 0 | #define lwsl_vhost_debug(_v, ...) lwsl_vhost(_v, LLL_DEBUG, __VA_ARGS__) |
479 | | #else |
480 | | #define lwsl_vhost_debug(_v, ...) do {} while(0) |
481 | | #endif |
482 | | |
483 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
484 | | #define lwsl_vhost_parser(_v, ...) lwsl_vhost(_v, LLL_PARSER, __VA_ARGS__) |
485 | | #else |
486 | | #define lwsl_vhost_parser(_v, ...) do {} while(0) |
487 | | #endif |
488 | | |
489 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
490 | | #define lwsl_vhost_header(_v, ...) lwsl_vhost(_v, LLL_HEADER, __VA_ARGS__) |
491 | | #else |
492 | | #define lwsl_vhost_header(_v, ...) do {} while(0) |
493 | | #endif |
494 | | |
495 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
496 | | #define lwsl_vhost_ext(_v, ...) lwsl_vhost(_v, LLL_EXT, __VA_ARGS__) |
497 | | #else |
498 | | #define lwsl_vhost_ext(_v, ...) do {} while(0) |
499 | | #endif |
500 | | |
501 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
502 | | #define lwsl_vhost_client(_v, ...) lwsl_vhost(_v, LLL_CLIENT, __VA_ARGS__) |
503 | | #else |
504 | | #define lwsl_vhost_client(_v, ...) do {} while(0) |
505 | | #endif |
506 | | |
507 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
508 | | #define lwsl_vhost_latency(_v, ...) lwsl_vhost(_v, LLL_LATENCY, __VA_ARGS__) |
509 | | #else |
510 | | #define lwsl_vhost_latency(_v, ...) do {} while(0) |
511 | | #endif |
512 | | |
513 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
514 | | #define lwsl_vhost_thread(_v, ...) lwsl_vhost(_v, LLL_THREAD, __VA_ARGS__) |
515 | | #else |
516 | | #define lwsl_vhost_thread(_v, ...) do {} while(0) |
517 | | #endif |
518 | | |
519 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
520 | | #define lwsl_vhost_user(_v, ...) lwsl_vhost(_v, LLL_USER, __VA_ARGS__) |
521 | | #else |
522 | | #define lwsl_vhost_user(_v, ...) do {} while(0) |
523 | | #endif |
524 | | |
525 | | #define lwsl_hexdump_vhost_err(_v, ...) lwsl_hexdump_vhost(_v, LLL_ERR, __VA_ARGS__) |
526 | | #define lwsl_hexdump_vhost_warn(_v, ...) lwsl_hexdump_vhost(_v, LLL_WARN, __VA_ARGS__) |
527 | | #define lwsl_hexdump_vhost_notice(_v, ...) lwsl_hexdump_vhost(_v, LLL_NOTICE, __VA_ARGS__) |
528 | | #define lwsl_hexdump_vhost_info(_v, ...) lwsl_hexdump_vhost(_v, LLL_INFO, __VA_ARGS__) |
529 | | #define lwsl_hexdump_vhost_debug(_v, ...) lwsl_hexdump_vhost(_v, LLL_DEBUG, __VA_ARGS__) |
530 | | |
531 | | |
532 | | /* |
533 | | * lws_wsi |
534 | | */ |
535 | | |
536 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
537 | 0 | #define lwsl_wsi_err(_w, ...) lwsl_wsi(_w, LLL_ERR, __VA_ARGS__) |
538 | | #else |
539 | | #define lwsl_wsi_err(_w, ...) do {} while(0) |
540 | | #endif |
541 | | |
542 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
543 | 0 | #define lwsl_wsi_warn(_w, ...) lwsl_wsi(_w, LLL_WARN, __VA_ARGS__) |
544 | | #else |
545 | | #define lwsl_wsi_warn(_w, ...) do {} while(0) |
546 | | #endif |
547 | | |
548 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
549 | 0 | #define lwsl_wsi_notice(_w, ...) lwsl_wsi(_w, LLL_NOTICE, __VA_ARGS__) |
550 | | #else |
551 | | #define lwsl_wsi_notice(_w, ...) do {} while(0) |
552 | | #endif |
553 | | |
554 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
555 | 0 | #define lwsl_wsi_info(_w, ...) lwsl_wsi(_w, LLL_INFO, __VA_ARGS__) |
556 | | #else |
557 | | #define lwsl_wsi_info(_w, ...) do {} while(0) |
558 | | #endif |
559 | | |
560 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
561 | 0 | #define lwsl_wsi_debug(_w, ...) lwsl_wsi(_w, LLL_DEBUG, __VA_ARGS__) |
562 | | #else |
563 | | #define lwsl_wsi_debug(_w, ...) do {} while(0) |
564 | | #endif |
565 | | |
566 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
567 | 0 | #define lwsl_wsi_parser(_w, ...) lwsl_wsi(_w, LLL_PARSER, __VA_ARGS__) |
568 | | #else |
569 | | #define lwsl_wsi_parser(_w, ...) do {} while(0) |
570 | | #endif |
571 | | |
572 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
573 | | #define lwsl_wsi_header(_w, ...) lwsl_wsi(_w, LLL_HEADER, __VA_ARGS__) |
574 | | #else |
575 | | #define lwsl_wsi_header(_w, ...) do {} while(0) |
576 | | #endif |
577 | | |
578 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
579 | 0 | #define lwsl_wsi_ext(_w, ...) lwsl_wsi(_w, LLL_EXT, __VA_ARGS__) |
580 | | #else |
581 | | #define lwsl_wsi_ext(_w, ...) do {} while(0) |
582 | | #endif |
583 | | |
584 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
585 | | #define lwsl_wsi_client(_w, ...) lwsl_wsi(_w, LLL_CLIENT, __VA_ARGS__) |
586 | | #else |
587 | | #define lwsl_wsi_client(_w, ...) do {} while(0) |
588 | | #endif |
589 | | |
590 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
591 | | #define lwsl_wsi_latency(_w, ...) lwsl_wsi(_w, LLL_LATENCY, __VA_ARGS__) |
592 | | #else |
593 | | #define lwsl_wsi_latency(_w, ...) do {} while(0) |
594 | | #endif |
595 | | |
596 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
597 | | #define lwsl_wsi_thread(_w, ...) lwsl_wsi(_w, LLL_THREAD, __VA_ARGS__) |
598 | | #else |
599 | | #define lwsl_wsi_thread(_w, ...) do {} while(0) |
600 | | #endif |
601 | | |
602 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
603 | | #define lwsl_wsi_user(_w, ...) lwsl_wsi(_w, LLL_USER, __VA_ARGS__) |
604 | | #else |
605 | | #define lwsl_wsi_user(_w, ...) do {} while(0) |
606 | | #endif |
607 | | |
608 | | #define lwsl_hexdump_wsi_err(_v, ...) lwsl_hexdump_wsi(_v, LLL_ERR, __VA_ARGS__) |
609 | | #define lwsl_hexdump_wsi_warn(_v, ...) lwsl_hexdump_wsi(_v, LLL_WARN, __VA_ARGS__) |
610 | | #define lwsl_hexdump_wsi_notice(_v, ...) lwsl_hexdump_wsi(_v, LLL_NOTICE, __VA_ARGS__) |
611 | 0 | #define lwsl_hexdump_wsi_info(_v, ...) lwsl_hexdump_wsi(_v, LLL_INFO, __VA_ARGS__) |
612 | 0 | #define lwsl_hexdump_wsi_debug(_v, ...) lwsl_hexdump_wsi(_v, LLL_DEBUG, __VA_ARGS__) |
613 | | #define lwsl_hexdump_wsi_user(_v, ...) lwsl_hexdump_wsi(_v, LLL_USER, __VA_ARGS__) |
614 | | |
615 | | |
616 | | |
617 | | /* |
618 | | * lwsl_ss |
619 | | */ |
620 | | |
621 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
622 | 0 | #define lwsl_ss_err(_w, ...) lwsl_ss(_w, LLL_ERR, __VA_ARGS__) |
623 | | #else |
624 | | #define lwsl_ss_err(_w, ...) do {} while(0) |
625 | | #endif |
626 | | |
627 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
628 | 0 | #define lwsl_ss_warn(_w, ...) lwsl_ss(_w, LLL_WARN, __VA_ARGS__) |
629 | | #else |
630 | | #define lwsl_ss_warn(_w, ...) do {} while(0) |
631 | | #endif |
632 | | |
633 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
634 | 0 | #define lwsl_ss_notice(_w, ...) lwsl_ss(_w, LLL_NOTICE, __VA_ARGS__) |
635 | | #else |
636 | | #define lwsl_ss_notice(_w, ...) do {} while(0) |
637 | | #endif |
638 | | |
639 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
640 | 0 | #define lwsl_ss_info(_w, ...) lwsl_ss(_w, LLL_INFO, __VA_ARGS__) |
641 | | #else |
642 | | #define lwsl_ss_info(_w, ...) do {} while(0) |
643 | | #endif |
644 | | |
645 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
646 | 0 | #define lwsl_ss_debug(_w, ...) lwsl_ss(_w, LLL_DEBUG, __VA_ARGS__) |
647 | | #else |
648 | | #define lwsl_ss_debug(_w, ...) do {} while(0) |
649 | | #endif |
650 | | |
651 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
652 | | #define lwsl_ss_parser(_w, ...) lwsl_ss(_w, LLL_PARSER, __VA_ARGS__) |
653 | | #else |
654 | | #define lwsl_ss_parser(_w, ...) do {} while(0) |
655 | | #endif |
656 | | |
657 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
658 | | #define lwsl_ss_header(_w, ...) lwsl_ss(_w, LLL_HEADER, __VA_ARGS__) |
659 | | #else |
660 | | #define lwsl_ss_header(_w, ...) do {} while(0) |
661 | | #endif |
662 | | |
663 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
664 | | #define lwsl_ss_ext(_w, ...) lwsl_ss(_w, LLL_EXT, __VA_ARGS__) |
665 | | #else |
666 | | #define lwsl_ss_ext(_w, ...) do {} while(0) |
667 | | #endif |
668 | | |
669 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
670 | | #define lwsl_ss_client(_w, ...) lwsl_ss(_w, LLL_CLIENT, __VA_ARGS__) |
671 | | #else |
672 | | #define lwsl_ss_client(_w, ...) do {} while(0) |
673 | | #endif |
674 | | |
675 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
676 | | #define lwsl_ss_latency(_w, ...) lwsl_ss(_w, LLL_LATENCY, __VA_ARGS__) |
677 | | #else |
678 | | #define lwsl_ss_latency(_w, ...) do {} while(0) |
679 | | #endif |
680 | | |
681 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
682 | | #define lwsl_ss_thread(_w, ...) lwsl_ss(_w, LLL_THREAD, __VA_ARGS__) |
683 | | #else |
684 | | #define lwsl_ss_thread(_w, ...) do {} while(0) |
685 | | #endif |
686 | | |
687 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
688 | | #define lwsl_ss_user(_w, ...) lwsl_ss(_w, LLL_USER, __VA_ARGS__) |
689 | | #else |
690 | | #define lwsl_ss_user(_w, ...) do {} while(0) |
691 | | #endif |
692 | | |
693 | | #define lwsl_hexdump_ss_err(_v, ...) lwsl_hexdump_ss(_v, LLL_ERR, __VA_ARGS__) |
694 | | #define lwsl_hexdump_ss_warn(_v, ...) lwsl_hexdump_ss(_v, LLL_WARN, __VA_ARGS__) |
695 | | #define lwsl_hexdump_ss_notice(_v, ...) lwsl_hexdump_ss(_v, LLL_NOTICE, __VA_ARGS__) |
696 | | #define lwsl_hexdump_ss_info(_v, ...) lwsl_hexdump_ss(_v, LLL_INFO, __VA_ARGS__) |
697 | | #define lwsl_hexdump_ss_debug(_v, ...) lwsl_hexdump_ss(_v, LLL_DEBUG, __VA_ARGS__) |
698 | | |
699 | | |
700 | | |
701 | | /** |
702 | | * lwsl_hexdump_level() - helper to hexdump a buffer at a selected debug level |
703 | | * |
704 | | * \param level: one of LLL_ constants |
705 | | * \param vbuf: buffer start to dump |
706 | | * \param len: length of buffer to dump |
707 | | * |
708 | | * If \p level is visible, does a nice hexdump -C style dump of \p vbuf for |
709 | | * \p len bytes. This can be extremely convenient while debugging. |
710 | | */ |
711 | | LWS_VISIBLE LWS_EXTERN void |
712 | | lwsl_hexdump_level(int level, const void *vbuf, size_t len); |
713 | | |
714 | | LWS_VISIBLE LWS_EXTERN void |
715 | | lwsl_hexdump_level_cx(lws_log_cx_t *cx, lws_log_prepend_cx_t prep, void *obj, |
716 | | int hexdump_level, const void *vbuf, size_t len); |
717 | | |
718 | | /** |
719 | | * lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only) |
720 | | * |
721 | | * \param buf: buffer start to dump |
722 | | * \param len: length of buffer to dump |
723 | | * |
724 | | * Calls through to lwsl_hexdump_level(LLL_DEBUG, ... for compatability. |
725 | | * It's better to use lwsl_hexdump_level(level, ... directly so you can control |
726 | | * the visibility. |
727 | | */ |
728 | | LWS_VISIBLE LWS_EXTERN void |
729 | | lwsl_hexdump(const void *buf, size_t len); |
730 | | |
731 | | /** |
732 | | * lws_is_be() - returns nonzero if the platform is Big Endian |
733 | | */ |
734 | 0 | static LWS_INLINE int lws_is_be(void) { |
735 | 0 | const int probe = ~0xff; |
736 | 0 |
|
737 | 0 | return *(const char *)&probe; |
738 | 0 | } Unexecuted instantiation: upng-gzip.c:lws_is_be Unexecuted instantiation: alloc.c:lws_is_be Unexecuted instantiation: logs.c:lws_is_be Unexecuted instantiation: unix-misc.c:lws_is_be Unexecuted instantiation: lws_dll2.c:lws_is_be Unexecuted instantiation: context.c:lws_is_be Unexecuted instantiation: libwebsockets.c:lws_is_be Unexecuted instantiation: lws-cache-ttl.c:lws_is_be Unexecuted instantiation: heap.c:lws_is_be Unexecuted instantiation: file.c:lws_is_be Unexecuted instantiation: dlo.c:lws_is_be Unexecuted instantiation: dlo-text.c:lws_is_be Unexecuted instantiation: dlo-png.c:lws_is_be Unexecuted instantiation: dlo-jpeg.c:lws_is_be Unexecuted instantiation: dir-notify.c:lws_is_be Unexecuted instantiation: lwsac.c:lws_is_be Unexecuted instantiation: stdin.c:lws_is_be Unexecuted instantiation: system.c:lws_is_be Unexecuted instantiation: smd.c:lws_is_be Unexecuted instantiation: close.c:lws_is_be Unexecuted instantiation: network.c:lws_is_be Unexecuted instantiation: vhost.c:lws_is_be Unexecuted instantiation: pollfd.c:lws_is_be Unexecuted instantiation: service.c:lws_is_be Unexecuted instantiation: sorted-usec-list.c:lws_is_be Unexecuted instantiation: wsi.c:lws_is_be Unexecuted instantiation: wsi-timeout.c:lws_is_be Unexecuted instantiation: adopt.c:lws_is_be Unexecuted instantiation: ops-pipe.c:lws_is_be Unexecuted instantiation: stub.c:lws_is_be Unexecuted instantiation: async-ipc.c:lws_is_be Unexecuted instantiation: state.c:lws_is_be Unexecuted instantiation: client.c:lws_is_be Unexecuted instantiation: connect.c:lws_is_be Unexecuted instantiation: connect2.c:lws_is_be Unexecuted instantiation: connect3.c:lws_is_be Unexecuted instantiation: connect4.c:lws_is_be Unexecuted instantiation: sort-dns.c:lws_is_be Unexecuted instantiation: conmon.c:lws_is_be Unexecuted instantiation: header.c:lws_is_be Unexecuted instantiation: date.c:lws_is_be Unexecuted instantiation: parsers.c:lws_is_be Unexecuted instantiation: server.c:lws_is_be Unexecuted instantiation: ops-h1.c:lws_is_be Unexecuted instantiation: http2.c:lws_is_be Unexecuted instantiation: hpack.c:lws_is_be Unexecuted instantiation: ops-h2.c:lws_is_be Unexecuted instantiation: ops-ws.c:lws_is_be Unexecuted instantiation: client-ws.c:lws_is_be Unexecuted instantiation: client-parser-ws.c:lws_is_be Unexecuted instantiation: server-ws.c:lws_is_be Unexecuted instantiation: ops-raw-skt.c:lws_is_be Unexecuted instantiation: ops-raw-file.c:lws_is_be Unexecuted instantiation: ops-listen.c:lws_is_be Unexecuted instantiation: client-http.c:lws_is_be Unexecuted instantiation: altsvc.c:lws_is_be Unexecuted instantiation: ops-netlink.c:lws_is_be Unexecuted instantiation: poll.c:lws_is_be Unexecuted instantiation: secure-streams.c:lws_is_be Unexecuted instantiation: policy-common.c:lws_is_be Unexecuted instantiation: captive-portal-detect.c:lws_is_be Unexecuted instantiation: ss-raw.c:lws_is_be Unexecuted instantiation: policy-json.c:lws_is_be Unexecuted instantiation: fetch-policy.c:lws_is_be Unexecuted instantiation: ss-h1.c:lws_is_be Unexecuted instantiation: ss-h2.c:lws_is_be Unexecuted instantiation: ss-ws.c:lws_is_be Unexecuted instantiation: unix-caps.c:lws_is_be Unexecuted instantiation: unix-init.c:lws_is_be Unexecuted instantiation: unix-file.c:lws_is_be Unexecuted instantiation: unix-pipe.c:lws_is_be Unexecuted instantiation: unix-service.c:lws_is_be Unexecuted instantiation: unix-sockets.c:lws_is_be Unexecuted instantiation: unix-fds.c:lws_is_be Unexecuted instantiation: unix-spawn.c:lws_is_be Unexecuted instantiation: tls.c:lws_is_be Unexecuted instantiation: tls-network.c:lws_is_be Unexecuted instantiation: openssl-tls.c:lws_is_be Unexecuted instantiation: openssl-x509.c:lws_is_be Unexecuted instantiation: openssl-ssl.c:lws_is_be Unexecuted instantiation: openssl-session.c:lws_is_be Unexecuted instantiation: lws-genhash.c:lws_is_be Unexecuted instantiation: tls-server.c:lws_is_be Unexecuted instantiation: openssl-server.c:lws_is_be Unexecuted instantiation: tls-client.c:lws_is_be Unexecuted instantiation: openssl-client.c:lws_is_be Unexecuted instantiation: lws-gencrypto-common.c:lws_is_be Unexecuted instantiation: buflist.c:lws_is_be Unexecuted instantiation: vfs.c:lws_is_be Unexecuted instantiation: base64-decode.c:lws_is_be Unexecuted instantiation: upng.c:lws_is_be Unexecuted instantiation: jpeg.c:lws_is_be Unexecuted instantiation: dlo-font-mcufont.c:lws_is_be Unexecuted instantiation: dir.c:lws_is_be Unexecuted instantiation: sha-1.c:lws_is_be Unexecuted instantiation: lejp.c:lws_is_be Unexecuted instantiation: policy.c:lws_is_be Unexecuted instantiation: dummy-callback.c:lws_is_be Unexecuted instantiation: output.c:lws_is_be Unexecuted instantiation: route.c:lws_is_be Unexecuted instantiation: cookie.c:lws_is_be Unexecuted instantiation: tls-sessions.c:lws_is_be |
739 | | |
740 | | /** |
741 | | * lws_set_log_level() - Set the logging bitfield |
742 | | * \param level: OR together the LLL_ debug contexts you want output from |
743 | | * \param log_emit_function: NULL to leave it as it is, or a user-supplied |
744 | | * function to perform log string emission instead of |
745 | | * the default stderr one. |
746 | | * |
747 | | * log level defaults to "err", "warn" and "notice" contexts enabled and |
748 | | * emission on stderr. If stderr is a tty (according to isatty()) then |
749 | | * the output is coloured according to the log level using ANSI escapes. |
750 | | * |
751 | | * You can set the default security level for logging using the |
752 | | * secrecy_and_log_level() macro to set the \p level parameter, eg |
753 | | * |
754 | | * lws_set_log_level(secrecy_and_log_level(LWS_SECRECY_PII, LLL_ERR | LLL_WARN), |
755 | | * my_emit_function); |
756 | | * |
757 | | * Normally you can just leave it at the default. |
758 | | */ |
759 | | LWS_VISIBLE LWS_EXTERN void |
760 | | lws_set_log_level(int level, lws_log_emit_t log_emit_function); |
761 | | |
762 | | /** |
763 | | * lwsl_emit_syslog() - helper log emit function writes to system log |
764 | | * |
765 | | * \param level: one of LLL_ log level indexes |
766 | | * \param line: log string |
767 | | * |
768 | | * You use this by passing the function pointer to lws_set_log_level(), to set |
769 | | * it as the log emit function, it is not called directly. |
770 | | */ |
771 | | LWS_VISIBLE LWS_EXTERN void |
772 | | lwsl_emit_syslog(int level, const char *line); |
773 | | |
774 | | /** |
775 | | * lwsl_emit_stderr() - helper log emit function writes to stderr |
776 | | * |
777 | | * \param level: one of LLL_ log level indexes |
778 | | * \param line: log string |
779 | | * |
780 | | * You use this by passing the function pointer to lws_set_log_level(), to set |
781 | | * it as the log emit function, it is not called directly. |
782 | | * |
783 | | * It prepends a system timestamp like [2018/11/13 07:41:57:3989] |
784 | | * |
785 | | * If stderr is a tty, then ansi colour codes are added. |
786 | | */ |
787 | | LWS_VISIBLE LWS_EXTERN void |
788 | | lwsl_emit_stderr(int level, const char *line); |
789 | | |
790 | | /** |
791 | | * lwsl_emit_stderr_notimestamp() - helper log emit function writes to stderr |
792 | | * |
793 | | * \param level: one of LLL_ log level indexes |
794 | | * \param line: log string |
795 | | * |
796 | | * You use this by passing the function pointer to lws_set_log_level(), to set |
797 | | * it as the log emit function, it is not called directly. |
798 | | * |
799 | | * If stderr is a tty, then ansi colour codes are added. |
800 | | */ |
801 | | LWS_VISIBLE LWS_EXTERN void |
802 | | lwsl_emit_stderr_notimestamp(int level, const char *line); |
803 | | |
804 | | /** |
805 | | * lwsl_visible() - returns true if the log level should be printed |
806 | | * |
807 | | * \param level: one of LLL_ log level indexes |
808 | | * |
809 | | * This is useful if you have to do work to generate the log content, you |
810 | | * can skip the work if the log level used to print it is not actually |
811 | | * enabled at runtime. |
812 | | */ |
813 | | LWS_VISIBLE LWS_EXTERN int |
814 | | lwsl_visible(int level); |
815 | | |
816 | | struct lws; |
817 | | |
818 | | LWS_VISIBLE LWS_EXTERN const char * |
819 | | lws_wsi_tag(struct lws *wsi); |
820 | | |
821 | | LWS_VISIBLE LWS_EXTERN void |
822 | | lwsl_refcount_cx(lws_log_cx_t *cx, int _new); |
823 | | |
824 | | ///@} |
825 | | |
826 | | /* |
827 | | * Ratelimited process scope logs |
828 | | */ |
829 | | |
830 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
831 | | #define lwsl_ratelimit_err(_rl, _i, ...) \ |
832 | 0 | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
833 | 0 | _lws_log_rl(LLL_ERR, _c, __VA_ARGS__); } while(0) |
834 | | #else |
835 | | #define lwsl_ratelimit_err(_rl, _i, ...) do {} while(0) |
836 | | #endif |
837 | | |
838 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
839 | | #define lwsl_ratelimit_warn(_rl, _i, ...) \ |
840 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
841 | | _lws_log_rl(LLL_WARN, _c, __VA_ARGS__); } while(0) |
842 | | #else |
843 | | #define lwsl_ratelimit_warn(_rl, _i, ...) do {} while(0) |
844 | | #endif |
845 | | |
846 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
847 | | #define lwsl_ratelimit_notice(_rl, _i, ...) \ |
848 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
849 | | _lws_log_rl(LLL_NOTICE, _c, __VA_ARGS__); } while(0) |
850 | | #else |
851 | | #define lwsl_ratelimit_notice(_rl, _i, ...) do {} while(0) |
852 | | #endif |
853 | | |
854 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
855 | | #define lwsl_ratelimit_info(_rl, _i, ...) \ |
856 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
857 | | _lws_log_rl(LLL_INFO, _c, __VA_ARGS__); } while(0) |
858 | | #else |
859 | | #define lwsl_ratelimit_info(_rl, _i, ...) do {} while(0) |
860 | | #endif |
861 | | |
862 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
863 | | #define lwsl_ratelimit_debug(_rl, _i, ...) \ |
864 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
865 | | _lws_log_rl(LLL_DEBUG, _c, __VA_ARGS__); } while(0) |
866 | | #else |
867 | | #define lwsl_ratelimit_debug(_rl, _i, ...) do {} while(0) |
868 | | #endif |
869 | | |
870 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
871 | | #define lwsl_ratelimit_parser(_rl, _i, ...) \ |
872 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
873 | | _lws_log_rl(LLL_PARSER, _c, __VA_ARGS__); } while(0) |
874 | | #else |
875 | | #define lwsl_ratelimit_parser(_rl, _i, ...) do {} while(0) |
876 | | #endif |
877 | | |
878 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
879 | | #define lwsl_ratelimit_header(_rl, _i, ...) \ |
880 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
881 | | _lws_log_rl(LLL_HEADER, _c, __VA_ARGS__); } while(0) |
882 | | #else |
883 | | #define lwsl_ratelimit_header(_rl, _i, ...) do {} while(0) |
884 | | #endif |
885 | | |
886 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
887 | | #define lwsl_ratelimit_ext(_rl, _i, ...) \ |
888 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
889 | | _lws_log_rl(LLL_EXT, _c, __VA_ARGS__); } while(0) |
890 | | #else |
891 | | #define lwsl_ratelimit_ext(_rl, _i, ...) do {} while(0) |
892 | | #endif |
893 | | |
894 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
895 | | #define lwsl_ratelimit_client(_rl, _i, ...) \ |
896 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
897 | | _lws_log_rl(LLL_CLIENT, _c, __VA_ARGS__); } while(0) |
898 | | #else |
899 | | #define lwsl_ratelimit_client(_rl, _i, ...) do {} while(0) |
900 | | #endif |
901 | | |
902 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
903 | | #define lwsl_ratelimit_latency(_rl, _i, ...) \ |
904 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
905 | | _lws_log_rl(LLL_LATENCY, _c, __VA_ARGS__); } while(0) |
906 | | #else |
907 | | #define lwsl_ratelimit_latency(_rl, _i, ...) do {} while(0) |
908 | | #endif |
909 | | |
910 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
911 | | #define lwsl_ratelimit_thread(_rl, _i, ...) \ |
912 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
913 | | _lws_log_rl(LLL_THREAD, _c, __VA_ARGS__); } while(0) |
914 | | #else |
915 | | #define lwsl_ratelimit_thread(_rl, _i, ...) do {} while(0) |
916 | | #endif |
917 | | |
918 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
919 | | #define lwsl_ratelimit_user(_rl, _i, ...) \ |
920 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
921 | | _lws_log_rl(LLL_USER, _c, __VA_ARGS__); } while(0) |
922 | | #else |
923 | | #define lwsl_ratelimit_user(_rl, _i, ...) do {} while(0) |
924 | | #endif |
925 | | |
926 | | /* |
927 | | * Ratelimited lws_context scope logs |
928 | | */ |
929 | | |
930 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
931 | | #define lwsl_ratelimit_cx_err(_rl, _i, _o, ...) \ |
932 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
933 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_ERR, _c, __func__, __VA_ARGS__); } while(0) |
934 | | #else |
935 | | #define lwsl_ratelimit_cx_err(_rl, _i, _o, ...) do {} while(0) |
936 | | #endif |
937 | | |
938 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
939 | | #define lwsl_ratelimit_cx_warn(_rl, _i, _o, ...) \ |
940 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
941 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_WARN, _c, __func__, __VA_ARGS__); } while(0) |
942 | | #else |
943 | | #define lwsl_ratelimit_cx_warn(_rl, _i, _o, ...) do {} while(0) |
944 | | #endif |
945 | | |
946 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
947 | | #define lwsl_ratelimit_cx_notice(_rl, _i, _o, ...) \ |
948 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
949 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_NOTICE, _c, __func__, __VA_ARGS__); } while(0) |
950 | | #else |
951 | | #define lwsl_ratelimit_cx_notice(_rl, _i, _o, ...) do {} while(0) |
952 | | #endif |
953 | | |
954 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
955 | | #define lwsl_ratelimit_cx_info(_rl, _i, _o, ...) \ |
956 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
957 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_INFO, _c, __func__, __VA_ARGS__); } while(0) |
958 | | #else |
959 | | #define lwsl_ratelimit_cx_info(_rl, _i, _o, ...) do {} while(0) |
960 | | #endif |
961 | | |
962 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
963 | | #define lwsl_ratelimit_cx_debug(_rl, _i, _o, ...) \ |
964 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
965 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_DEBUG, _c, __func__, __VA_ARGS__); } while(0) |
966 | | #else |
967 | | #define lwsl_ratelimit_cx_debug(_rl, _i, _o, ...) do {} while(0) |
968 | | #endif |
969 | | |
970 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
971 | | #define lwsl_ratelimit_cx_parser(_rl, _i, _o, ...) \ |
972 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
973 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_PARSER, _c, __func__, __VA_ARGS__); } while(0) |
974 | | #else |
975 | | #define lwsl_ratelimit_cx_parser(_rl, _i, _o, ...) do {} while(0) |
976 | | #endif |
977 | | |
978 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
979 | | #define lwsl_ratelimit_cx_header(_rl, _i, _o, ...) \ |
980 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
981 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_HEADER, _c, __func__, __VA_ARGS__); } while(0) |
982 | | #else |
983 | | #define lwsl_ratelimit_cx_header(_rl, _i, _o, ...) do {} while(0) |
984 | | #endif |
985 | | |
986 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
987 | | #define lwsl_ratelimit_cx_ext(_rl, _i, _o, ...) \ |
988 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
989 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_EXT, _c, __func__, __VA_ARGS__); } while(0) |
990 | | #else |
991 | | #define lwsl_ratelimit_cx_ext(_rl, _i, _o, ...) do {} while(0) |
992 | | #endif |
993 | | |
994 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
995 | | #define lwsl_ratelimit_cx_client(_rl, _i, _o, ...) \ |
996 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
997 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_CLIENT, _c, __func__, __VA_ARGS__); } while(0) |
998 | | #else |
999 | | #define lwsl_ratelimit_cx_client(_rl, _i, _o, ...) do {} while(0) |
1000 | | #endif |
1001 | | |
1002 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
1003 | | #define lwsl_ratelimit_cx_latency(_rl, _i, _o, ...) \ |
1004 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1005 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_LATENCY, _c, __func__, __VA_ARGS__); } while(0) |
1006 | | #else |
1007 | | #define lwsl_ratelimit_cx_latency(_rl, _i, _o, ...) do {} while(0) |
1008 | | #endif |
1009 | | |
1010 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
1011 | | #define lwsl_ratelimit_cx_thread(_rl, _i, _o, ...) \ |
1012 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1013 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_THREAD, _c, __func__, __VA_ARGS__); } while(0) |
1014 | | #else |
1015 | | #define lwsl_ratelimit_cx_thread(_rl, _i, _o, ...) do {} while(0) |
1016 | | #endif |
1017 | | |
1018 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
1019 | | #define lwsl_ratelimit_cx_user(_rl, _i, _o, ...) \ |
1020 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1021 | | _lws_log_cx_rl(lwsl_context_get_cx(_o), lws_log_prepend_context, _o, LLL_USER, _c, __func__, __VA_ARGS__); } while(0) |
1022 | | #else |
1023 | | #define lwsl_ratelimit_cx_user(_rl, _i, _o, ...) do {} while(0) |
1024 | | #endif |
1025 | | |
1026 | | /* |
1027 | | * Ratelimited lws_vhost scope logs |
1028 | | */ |
1029 | | |
1030 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
1031 | | #define lwsl_ratelimit_vhost_err(_rl, _i, _o, ...) \ |
1032 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1033 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_ERR, _c, __func__, __VA_ARGS__); } while(0) |
1034 | | #else |
1035 | | #define lwsl_ratelimit_vhost_err(_rl, _i, _o, ...) do {} while(0) |
1036 | | #endif |
1037 | | |
1038 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
1039 | | #define lwsl_ratelimit_vhost_warn(_rl, _i, _o, ...) \ |
1040 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1041 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_WARN, _c, __func__, __VA_ARGS__); } while(0) |
1042 | | #else |
1043 | | #define lwsl_ratelimit_vhost_warn(_rl, _i, _o, ...) do {} while(0) |
1044 | | #endif |
1045 | | |
1046 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
1047 | | #define lwsl_ratelimit_vhost_notice(_rl, _i, _o, ...) \ |
1048 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1049 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_NOTICE, _c, __func__, __VA_ARGS__); } while(0) |
1050 | | #else |
1051 | | #define lwsl_ratelimit_vhost_notice(_rl, _i, _o, ...) do {} while(0) |
1052 | | #endif |
1053 | | |
1054 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
1055 | | #define lwsl_ratelimit_vhost_info(_rl, _i, _o, ...) \ |
1056 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1057 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_INFO, _c, __func__, __VA_ARGS__); } while(0) |
1058 | | #else |
1059 | | #define lwsl_ratelimit_vhost_info(_rl, _i, _o, ...) do {} while(0) |
1060 | | #endif |
1061 | | |
1062 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
1063 | | #define lwsl_ratelimit_vhost_debug(_rl, _i, _o, ...) \ |
1064 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1065 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_DEBUG, _c, __func__, __VA_ARGS__); } while(0) |
1066 | | #else |
1067 | | #define lwsl_ratelimit_vhost_debug(_rl, _i, _o, ...) do {} while(0) |
1068 | | #endif |
1069 | | |
1070 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
1071 | | #define lwsl_ratelimit_vhost_parser(_rl, _i, _o, ...) \ |
1072 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1073 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_PARSER, _c, __func__, __VA_ARGS__); } while(0) |
1074 | | #else |
1075 | | #define lwsl_ratelimit_vhost_parser(_rl, _i, _o, ...) do {} while(0) |
1076 | | #endif |
1077 | | |
1078 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
1079 | | #define lwsl_ratelimit_vhost_header(_rl, _i, _o, ...) \ |
1080 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1081 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_HEADER, _c, __func__, __VA_ARGS__); } while(0) |
1082 | | #else |
1083 | | #define lwsl_ratelimit_vhost_header(_rl, _i, _o, ...) do {} while(0) |
1084 | | #endif |
1085 | | |
1086 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
1087 | | #define lwsl_ratelimit_vhost_ext(_rl, _i, _o, ...) \ |
1088 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1089 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_EXT, _c, __func__, __VA_ARGS__); } while(0) |
1090 | | #else |
1091 | | #define lwsl_ratelimit_vhost_ext(_rl, _i, _o, ...) do {} while(0) |
1092 | | #endif |
1093 | | |
1094 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
1095 | | #define lwsl_ratelimit_vhost_client(_rl, _i, _o, ...) \ |
1096 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1097 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_CLIENT, _c, __func__, __VA_ARGS__); } while(0) |
1098 | | #else |
1099 | | #define lwsl_ratelimit_vhost_client(_rl, _i, _o, ...) do {} while(0) |
1100 | | #endif |
1101 | | |
1102 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
1103 | | #define lwsl_ratelimit_vhost_latency(_rl, _i, _o, ...) \ |
1104 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1105 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_LATENCY, _c, __func__, __VA_ARGS__); } while(0) |
1106 | | #else |
1107 | | #define lwsl_ratelimit_vhost_latency(_rl, _i, _o, ...) do {} while(0) |
1108 | | #endif |
1109 | | |
1110 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
1111 | | #define lwsl_ratelimit_vhost_thread(_rl, _i, _o, ...) \ |
1112 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1113 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_THREAD, _c, __func__, __VA_ARGS__); } while(0) |
1114 | | #else |
1115 | | #define lwsl_ratelimit_vhost_thread(_rl, _i, _o, ...) do {} while(0) |
1116 | | #endif |
1117 | | |
1118 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
1119 | | #define lwsl_ratelimit_vhost_user(_rl, _i, _o, ...) \ |
1120 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1121 | | _lws_log_cx_rl(lwsl_vhost_get_cx(_o), lws_log_prepend_vhost, _o, LLL_USER, _c, __func__, __VA_ARGS__); } while(0) |
1122 | | #else |
1123 | | #define lwsl_ratelimit_vhost_user(_rl, _i, _o, ...) do {} while(0) |
1124 | | #endif |
1125 | | |
1126 | | /* |
1127 | | * Ratelimited lws_wsi scope logs |
1128 | | */ |
1129 | | |
1130 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
1131 | | #define lwsl_ratelimit_wsi_err(_rl, _i, _o, ...) \ |
1132 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1133 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_ERR, _c, __func__, __VA_ARGS__); } while(0) |
1134 | | #else |
1135 | | #define lwsl_ratelimit_wsi_err(_rl, _i, _o, ...) do {} while(0) |
1136 | | #endif |
1137 | | |
1138 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
1139 | | #define lwsl_ratelimit_wsi_warn(_rl, _i, _o, ...) \ |
1140 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1141 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_WARN, _c, __func__, __VA_ARGS__); } while(0) |
1142 | | #else |
1143 | | #define lwsl_ratelimit_wsi_warn(_rl, _i, _o, ...) do {} while(0) |
1144 | | #endif |
1145 | | |
1146 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
1147 | | #define lwsl_ratelimit_wsi_notice(_rl, _i, _o, ...) \ |
1148 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1149 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_NOTICE, _c, __func__, __VA_ARGS__); } while(0) |
1150 | | #else |
1151 | | #define lwsl_ratelimit_wsi_notice(_rl, _i, _o, ...) do {} while(0) |
1152 | | #endif |
1153 | | |
1154 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
1155 | | #define lwsl_ratelimit_wsi_info(_rl, _i, _o, ...) \ |
1156 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1157 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_INFO, _c, __func__, __VA_ARGS__); } while(0) |
1158 | | #else |
1159 | | #define lwsl_ratelimit_wsi_info(_rl, _i, _o, ...) do {} while(0) |
1160 | | #endif |
1161 | | |
1162 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
1163 | | #define lwsl_ratelimit_wsi_debug(_rl, _i, _o, ...) \ |
1164 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1165 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_DEBUG, _c, __func__, __VA_ARGS__); } while(0) |
1166 | | #else |
1167 | | #define lwsl_ratelimit_wsi_debug(_rl, _i, _o, ...) do {} while(0) |
1168 | | #endif |
1169 | | |
1170 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
1171 | | #define lwsl_ratelimit_wsi_parser(_rl, _i, _o, ...) \ |
1172 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1173 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_PARSER, _c, __func__, __VA_ARGS__); } while(0) |
1174 | | #else |
1175 | | #define lwsl_ratelimit_wsi_parser(_rl, _i, _o, ...) do {} while(0) |
1176 | | #endif |
1177 | | |
1178 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
1179 | | #define lwsl_ratelimit_wsi_header(_rl, _i, _o, ...) \ |
1180 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1181 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_HEADER, _c, __func__, __VA_ARGS__); } while(0) |
1182 | | #else |
1183 | | #define lwsl_ratelimit_wsi_header(_rl, _i, _o, ...) do {} while(0) |
1184 | | #endif |
1185 | | |
1186 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
1187 | | #define lwsl_ratelimit_wsi_ext(_rl, _i, _o, ...) \ |
1188 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1189 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_EXT, _c, __func__, __VA_ARGS__); } while(0) |
1190 | | #else |
1191 | | #define lwsl_ratelimit_wsi_ext(_rl, _i, _o, ...) do {} while(0) |
1192 | | #endif |
1193 | | |
1194 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
1195 | | #define lwsl_ratelimit_wsi_client(_rl, _i, _o, ...) \ |
1196 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1197 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_CLIENT, _c, __func__, __VA_ARGS__); } while(0) |
1198 | | #else |
1199 | | #define lwsl_ratelimit_wsi_client(_rl, _i, _o, ...) do {} while(0) |
1200 | | #endif |
1201 | | |
1202 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
1203 | | #define lwsl_ratelimit_wsi_latency(_rl, _i, _o, ...) \ |
1204 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1205 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_LATENCY, _c, __func__, __VA_ARGS__); } while(0) |
1206 | | #else |
1207 | | #define lwsl_ratelimit_wsi_latency(_rl, _i, _o, ...) do {} while(0) |
1208 | | #endif |
1209 | | |
1210 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
1211 | | #define lwsl_ratelimit_wsi_thread(_rl, _i, _o, ...) \ |
1212 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1213 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_THREAD, _c, __func__, __VA_ARGS__); } while(0) |
1214 | | #else |
1215 | | #define lwsl_ratelimit_wsi_thread(_rl, _i, _o, ...) do {} while(0) |
1216 | | #endif |
1217 | | |
1218 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
1219 | | #define lwsl_ratelimit_wsi_user(_rl, _i, _o, ...) \ |
1220 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1221 | | _lws_log_cx_rl(lwsl_wsi_get_cx(_o), lws_log_prepend_wsi, _o, LLL_USER, _c, __func__, __VA_ARGS__); } while(0) |
1222 | | #else |
1223 | | #define lwsl_ratelimit_wsi_user(_rl, _i, _o, ...) do {} while(0) |
1224 | | #endif |
1225 | | |
1226 | | /* |
1227 | | * Ratelimited lws_ss scope logs |
1228 | | */ |
1229 | | |
1230 | | #if (_LWS_ENABLED_LOGS & LLL_ERR) |
1231 | | #define lwsl_ratelimit_ss_err(_rl, _i, _o, ...) \ |
1232 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1233 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_ERR, _c, __func__, __VA_ARGS__); } while(0) |
1234 | | #else |
1235 | | #define lwsl_ratelimit_ss_err(_rl, _i, _o, ...) do {} while(0) |
1236 | | #endif |
1237 | | |
1238 | | #if (_LWS_ENABLED_LOGS & LLL_WARN) |
1239 | | #define lwsl_ratelimit_ss_warn(_rl, _i, _o, ...) \ |
1240 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1241 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_WARN, _c, __func__, __VA_ARGS__); } while(0) |
1242 | | #else |
1243 | | #define lwsl_ratelimit_ss_warn(_rl, _i, _o, ...) do {} while(0) |
1244 | | #endif |
1245 | | |
1246 | | #if (_LWS_ENABLED_LOGS & LLL_NOTICE) |
1247 | | #define lwsl_ratelimit_ss_notice(_rl, _i, _o, ...) \ |
1248 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1249 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_NOTICE, _c, __func__, __VA_ARGS__); } while(0) |
1250 | | #else |
1251 | | #define lwsl_ratelimit_ss_notice(_rl, _i, _o, ...) do {} while(0) |
1252 | | #endif |
1253 | | |
1254 | | #if (_LWS_ENABLED_LOGS & LLL_INFO) |
1255 | | #define lwsl_ratelimit_ss_info(_rl, _i, _o, ...) \ |
1256 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1257 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_INFO, _c, __func__, __VA_ARGS__); } while(0) |
1258 | | #else |
1259 | | #define lwsl_ratelimit_ss_info(_rl, _i, _o, ...) do {} while(0) |
1260 | | #endif |
1261 | | |
1262 | | #if (_LWS_ENABLED_LOGS & LLL_DEBUG) |
1263 | | #define lwsl_ratelimit_ss_debug(_rl, _i, _o, ...) \ |
1264 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1265 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_DEBUG, _c, __func__, __VA_ARGS__); } while(0) |
1266 | | #else |
1267 | | #define lwsl_ratelimit_ss_debug(_rl, _i, _o, ...) do {} while(0) |
1268 | | #endif |
1269 | | |
1270 | | #if (_LWS_ENABLED_LOGS & LLL_PARSER) |
1271 | | #define lwsl_ratelimit_ss_parser(_rl, _i, _o, ...) \ |
1272 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1273 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_PARSER, _c, __func__, __VA_ARGS__); } while(0) |
1274 | | #else |
1275 | | #define lwsl_ratelimit_ss_parser(_rl, _i, _o, ...) do {} while(0) |
1276 | | #endif |
1277 | | |
1278 | | #if (_LWS_ENABLED_LOGS & LLL_HEADER) |
1279 | | #define lwsl_ratelimit_ss_header(_rl, _i, _o, ...) \ |
1280 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1281 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_HEADER, _c, __func__, __VA_ARGS__); } while(0) |
1282 | | #else |
1283 | | #define lwsl_ratelimit_ss_header(_rl, _i, _o, ...) do {} while(0) |
1284 | | #endif |
1285 | | |
1286 | | #if (_LWS_ENABLED_LOGS & LLL_EXT) |
1287 | | #define lwsl_ratelimit_ss_ext(_rl, _i, _o, ...) \ |
1288 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1289 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_EXT, _c, __func__, __VA_ARGS__); } while(0) |
1290 | | #else |
1291 | | #define lwsl_ratelimit_ss_ext(_rl, _i, _o, ...) do {} while(0) |
1292 | | #endif |
1293 | | |
1294 | | #if (_LWS_ENABLED_LOGS & LLL_CLIENT) |
1295 | | #define lwsl_ratelimit_ss_client(_rl, _i, _o, ...) \ |
1296 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1297 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_CLIENT, _c, __func__, __VA_ARGS__); } while(0) |
1298 | | #else |
1299 | | #define lwsl_ratelimit_ss_client(_rl, _i, _o, ...) do {} while(0) |
1300 | | #endif |
1301 | | |
1302 | | #if (_LWS_ENABLED_LOGS & LLL_LATENCY) |
1303 | | #define lwsl_ratelimit_ss_latency(_rl, _i, _o, ...) \ |
1304 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1305 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_LATENCY, _c, __func__, __VA_ARGS__); } while(0) |
1306 | | #else |
1307 | | #define lwsl_ratelimit_ss_latency(_rl, _i, _o, ...) do {} while(0) |
1308 | | #endif |
1309 | | |
1310 | | #if (_LWS_ENABLED_LOGS & LLL_THREAD) |
1311 | | #define lwsl_ratelimit_ss_thread(_rl, _i, _o, ...) \ |
1312 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1313 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_THREAD, _c, __func__, __VA_ARGS__); } while(0) |
1314 | | #else |
1315 | | #define lwsl_ratelimit_ss_thread(_rl, _i, _o, ...) do {} while(0) |
1316 | | #endif |
1317 | | |
1318 | | #if (_LWS_ENABLED_LOGS & LLL_USER) |
1319 | | #define lwsl_ratelimit_ss_user(_rl, _i, _o, ...) \ |
1320 | | do { uint32_t _c = lws_log_ratelimit_check(_rl, _i); if (_c) \ |
1321 | | _lws_log_cx_rl(lwsl_ss_get_cx(_o), lws_log_prepend_ss, _o, LLL_USER, _c, __func__, __VA_ARGS__); } while(0) |
1322 | | #else |
1323 | | #define lwsl_ratelimit_ss_user(_rl, _i, _o, ...) do {} while(0) |
1324 | | #endif |