libwebsockets
Lightweight C library for HTML5 websockets
lws-logs.h
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 
39 
40 #define LLL_ERR (1 << 0)
41 #define LLL_WARN (1 << 1)
42 #define LLL_NOTICE (1 << 2)
43 #define LLL_INFO (1 << 3)
44 #define LLL_DEBUG (1 << 4)
45 #define LLL_PARSER (1 << 5)
46 #define LLL_HEADER (1 << 6)
47 #define LLL_EXT (1 << 7)
48 #define LLL_CLIENT (1 << 8)
49 #define LLL_LATENCY (1 << 9)
50 #define LLL_USER (1 << 10)
51 #define LLL_THREAD (1 << 11)
52 
53 #define LLL_COUNT (12) /* set to count of valid flags */
54 
55 #define LLLF_SECRECY_PII (1 << 16)
57 #define LLLF_SECRECY_BEARER (1 << 17)
60 #define LLLF_LOG_TIMESTAMP (1 << 18)
63 #define LLLF_LOG_CONTEXT_AWARE (1 << 30)
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  lws_log_emit_t emit; /* legacy emit function */
83  lws_log_emit_cx_t emit_cx; /* LLLF_LOG_CONTEXT_AWARE */
84  } u;
85  lws_log_use_cx_t refcount_cb;
89  lws_log_prepend_cx_t prepend;
92  struct lws_log_cx *parent;
94  void *opaque;
96  void *stg;
98  uint32_t lll_flags;
100  int32_t refcount;
102 } lws_log_cx_t;
103 
113 LWS_VISIBLE LWS_EXTERN int
114 lwsl_timestamp(int level, char *p, size_t len);
115 
116 #if defined(LWS_PLAT_OPTEE) && !defined(LWS_WITH_NETWORK)
117 #define _lws_log(aaa, ...) SMSG(__VA_ARGS__)
118 #else
119 LWS_VISIBLE LWS_EXTERN void
120 _lws_log(int filter, const char *format, ...) LWS_FORMAT(2);
121 LWS_VISIBLE LWS_EXTERN void
122 _lws_logv(int filter, const char *format, va_list vl);
123 #endif
124 
125 struct lws_vhost;
126 struct lws;
127 
128 LWS_VISIBLE LWS_EXTERN struct lws_log_cx *
129 lwsl_context_get_cx(struct lws_context *cx);
130 LWS_VISIBLE LWS_EXTERN struct lws_log_cx *
131 lwsl_vhost_get_cx(struct lws_vhost *vh);
132 LWS_VISIBLE LWS_EXTERN struct lws_log_cx *
133 lwsl_wsi_get_cx(struct lws *wsi);
134 #if defined(LWS_WITH_SECURE_STREAMS)
135 struct lws_ss_handle;
136 LWS_VISIBLE LWS_EXTERN struct lws_log_cx *
137 lwsl_ss_get_cx(struct lws_ss_handle *ss);
138 #endif
139 #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
140 struct lws_sspc_handle;
141 LWS_VISIBLE LWS_EXTERN struct lws_log_cx *
142 lwsl_sspc_get_cx(struct lws_sspc_handle *ss);
143 #endif
144 
145 
146 LWS_VISIBLE LWS_EXTERN void
147 lws_log_emit_cx_file(struct lws_log_cx *cx, int level, const char *line,
148  size_t len);
149 
150 LWS_VISIBLE LWS_EXTERN void
151 lws_log_use_cx_file(struct lws_log_cx *cx, int _new);
152 
153 LWS_VISIBLE LWS_EXTERN void
154 lws_log_prepend_context(struct lws_log_cx *cx, void *obj, char **p, char *e);
155 LWS_VISIBLE LWS_EXTERN void
156 lws_log_prepend_vhost(struct lws_log_cx *cx, void *obj, char **p, char *e);
157 LWS_VISIBLE LWS_EXTERN void
158 lws_log_prepend_wsi(struct lws_log_cx *cx, void *obj, char **p, char *e);
159 #if defined(LWS_WITH_SECURE_STREAMS)
160 LWS_VISIBLE LWS_EXTERN void
161 lws_log_prepend_ss(struct lws_log_cx *cx, void *obj, char **p, char *e);
162 #endif
163 #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
164 LWS_VISIBLE LWS_EXTERN void
165 lws_log_prepend_sspc(struct lws_log_cx *cx, void *obj, char **p, char *e);
166 #endif
167 
168 LWS_VISIBLE LWS_EXTERN void
169 _lws_log_cx(lws_log_cx_t *cx, lws_log_prepend_cx_t prep, void *obj,
170  int filter, const char *_fun, const char *format, ...) LWS_FORMAT(6);
171 
172 #define lwsl_cx(_c, _fil, ...) \
173  _lws_log_cx(lwsl_context_get_cx(_c), lws_log_prepend_context, \
174  _c, _fil, __func__, __VA_ARGS__)
175 #define lwsl_vhost(_v, _fil, ...) \
176  _lws_log_cx(lwsl_vhost_get_cx(_v), lws_log_prepend_vhost, _v, \
177  _fil, __func__, __VA_ARGS__)
178 #define lwsl_wsi(_w, _fil, ...) \
179  _lws_log_cx(lwsl_wsi_get_cx(_w), lws_log_prepend_wsi, _w, \
180  _fil, __func__, __VA_ARGS__)
181 #define lwsl_ss(_h, _fil, ...) \
182  _lws_log_cx(lwsl_ss_get_cx(_h), lws_log_prepend_ss, _h, \
183  _fil, __func__, __VA_ARGS__)
184 
185 #define lwsl_hexdump_context(_c, _fil, _buf, _len) \
186  lwsl_hexdump_level_cx(lwsl_context_get_cx(_c), \
187  lws_log_prepend_context, \
188  _c, _fil, _buf, _len)
189 #define lwsl_hexdump_vhost(_v, _fil, _buf, _len) \
190  lwsl_hexdump_level_cx(lwsl_vhost_get_cx(_v), \
191  lws_log_prepend_vhost, \
192  _v, _fil, _buf, _len)
193 #define lwsl_hexdump_wsi(_w, _fil, _buf, _len) \
194  lwsl_hexdump_level_cx(lwsl_wsi_get_cx(_w), \
195  lws_log_prepend_wsi, \
196  _w, _fil, _buf, _len)
197 #define lwsl_hexdump_ss(_h, _fil, _buf, _len) \
198  lwsl_hexdump_level_cx(lwsl_ss_get_cx(_h), \
199  lws_log_prepend_ss, \
200  _h, _fil, _buf, _len)
201 
202 /*
203  * Figure out which logs to build in or not
204  */
205 
206 #if defined(_DEBUG)
207  /*
208  * In DEBUG build, select all logs unless NO_LOGS
209  */
210  #if defined(LWS_WITH_NO_LOGS)
211  #define _LWS_LINIT (LLL_ERR | LLL_USER)
212  #else
213  #define _LWS_LINIT ((1 << LLL_COUNT) - 1)
214  #endif
215 #else /* not _DEBUG */
216 #if defined(LWS_WITH_NO_LOGS)
217 #define _LWS_LINIT (LLL_ERR | LLL_USER)
218 #else
219  #define _LWS_LINIT (LLL_ERR | LLL_USER | LLL_WARN | LLL_NOTICE)
220 #endif
221 #endif /* _DEBUG */
222 
223 /*
224  * Create either empty overrides or the ones forced at build-time.
225  * These overrides have the final say... any bits set in
226  * LWS_LOGGING_BITFIELD_SET force the build of those logs, any bits
227  * set in LWS_LOGGING_BITFIELD_CLEAR disable the build of those logs.
228  *
229  * If not defined lws decides based on CMAKE_BUILD_TYPE=DEBUG or not
230  */
231 
232 #if defined(LWS_LOGGING_BITFIELD_SET)
233  #define _LWS_LBS (LWS_LOGGING_BITFIELD_SET)
234 #else
235  #define _LWS_LBS 0
236 #endif
237 
238 #if defined(LWS_LOGGING_BITFIELD_CLEAR)
239  #define _LWS_LBC (LWS_LOGGING_BITFIELD_CLEAR)
240 #else
241  #define _LWS_LBC 0
242 #endif
243 
244 /*
245  * Compute the final active logging bitfield for build
246  */
247 #define _LWS_ENABLED_LOGS (((_LWS_LINIT) | (_LWS_LBS)) & ~(_LWS_LBC))
248 
249 /*
250  * Individually enable or disable log levels for build
251  * depending on what was computed
252  */
253 
254 /*
255  * Process scope logs
256  */
257 
258 #if (_LWS_ENABLED_LOGS & LLL_ERR)
259 #define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)
260 #else
261 #define lwsl_err(...) do {} while(0)
262 #endif
263 
264 #if (_LWS_ENABLED_LOGS & LLL_WARN)
265 #define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__)
266 #else
267 #define lwsl_warn(...) do {} while(0)
268 #endif
269 
270 #if (_LWS_ENABLED_LOGS & LLL_NOTICE)
271 #define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)
272 #else
273 #define lwsl_notice(...) do {} while(0)
274 #endif
275 
276 #if (_LWS_ENABLED_LOGS & LLL_INFO)
277 #define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__)
278 #else
279 #define lwsl_info(...) do {} while(0)
280 #endif
281 
282 #if (_LWS_ENABLED_LOGS & LLL_DEBUG)
283 #define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__)
284 #else
285 #define lwsl_debug(...) do {} while(0)
286 #endif
287 
288 #if (_LWS_ENABLED_LOGS & LLL_PARSER)
289 #define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__)
290 #else
291 #define lwsl_parser(...) do {} while(0)
292 #endif
293 
294 #if (_LWS_ENABLED_LOGS & LLL_HEADER)
295 #define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__)
296 #else
297 #define lwsl_header(...) do {} while(0)
298 #endif
299 
300 #if (_LWS_ENABLED_LOGS & LLL_EXT)
301 #define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__)
302 #else
303 #define lwsl_ext(...) do {} while(0)
304 #endif
305 
306 #if (_LWS_ENABLED_LOGS & LLL_CLIENT)
307 #define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__)
308 #else
309 #define lwsl_client(...) do {} while(0)
310 #endif
311 
312 #if (_LWS_ENABLED_LOGS & LLL_LATENCY)
313 #define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__)
314 #else
315 #define lwsl_latency(...) do {} while(0)
316 #endif
317 
318 #if (_LWS_ENABLED_LOGS & LLL_THREAD)
319 #define lwsl_thread(...) _lws_log(LLL_THREAD, __VA_ARGS__)
320 #else
321 #define lwsl_thread(...) do {} while(0)
322 #endif
323 
324 #if (_LWS_ENABLED_LOGS & LLL_USER)
325 #define lwsl_user(...) _lws_log(LLL_USER, __VA_ARGS__)
326 #else
327 #define lwsl_user(...) do {} while(0)
328 #endif
329 
330 #define lwsl_hexdump_err(...) lwsl_hexdump_level(LLL_ERR, __VA_ARGS__)
331 #define lwsl_hexdump_warn(...) lwsl_hexdump_level(LLL_WARN, __VA_ARGS__)
332 #define lwsl_hexdump_notice(...) lwsl_hexdump_level(LLL_NOTICE, __VA_ARGS__)
333 #define lwsl_hexdump_info(...) lwsl_hexdump_level(LLL_INFO, __VA_ARGS__)
334 #define lwsl_hexdump_debug(...) lwsl_hexdump_level(LLL_DEBUG, __VA_ARGS__)
335 
336 /*
337  * lws_context scope logs
338  */
339 
340 #if (_LWS_ENABLED_LOGS & LLL_ERR)
341 #define lwsl_cx_err(_c, ...) lwsl_cx(_c, LLL_ERR, __VA_ARGS__)
342 #else
343 #define lwsl_cx_err(_c, ...) do {} while(0)
344 #endif
345 
346 #if (_LWS_ENABLED_LOGS & LLL_WARN)
347 #define lwsl_cx_warn(_c, ...) lwsl_cx(_c, LLL_WARN, __VA_ARGS__)
348 #else
349 #define lwsl_cx_warn(_c, ...) do {} while(0)
350 #endif
351 
352 #if (_LWS_ENABLED_LOGS & LLL_NOTICE)
353 #define lwsl_cx_notice(_c, ...) lwsl_cx(_c, LLL_NOTICE, __VA_ARGS__)
354 #else
355 #define lwsl_cx_notice(_c, ...) do {} while(0)
356 #endif
357 
358 #if (_LWS_ENABLED_LOGS & LLL_INFO)
359 #define lwsl_cx_info(_c, ...) lwsl_cx(_c, LLL_INFO, __VA_ARGS__)
360 #else
361 #define lwsl_cx_info(_c, ...) do {} while(0)
362 #endif
363 
364 #if (_LWS_ENABLED_LOGS & LLL_DEBUG)
365 #define lwsl_cx_debug(_c, ...) lwsl_cx(_c, LLL_DEBUG, __VA_ARGS__)
366 #else
367 #define lwsl_cx_debug(_c, ...) do {} while(0)
368 #endif
369 
370 #if (_LWS_ENABLED_LOGS & LLL_PARSER)
371 #define lwsl_cx_parser(_c, ...) lwsl_cx(_c, LLL_PARSER, __VA_ARGS__)
372 #else
373 #define lwsl_cx_parser(_c, ...) do {} while(0)
374 #endif
375 
376 #if (_LWS_ENABLED_LOGS & LLL_HEADER)
377 #define lwsl_cx_header(_c, ...) lwsl_cx(_c, LLL_HEADER, __VA_ARGS__)
378 #else
379 #define lwsl_cx_header(_c, ...) do {} while(0)
380 #endif
381 
382 #if (_LWS_ENABLED_LOGS & LLL_EXT)
383 #define lwsl_cx_ext(_c, ...) lwsl_cx(_c, LLL_EXT, __VA_ARGS__)
384 #else
385 #define lwsl_cx_ext(_c, ...) do {} while(0)
386 #endif
387 
388 #if (_LWS_ENABLED_LOGS & LLL_CLIENT)
389 #define lwsl_cx_client(_c, ...) lwsl_cx(_c, LLL_CLIENT, __VA_ARGS__)
390 #else
391 #define lwsl_cx_client(_c, ...) do {} while(0)
392 #endif
393 
394 #if (_LWS_ENABLED_LOGS & LLL_LATENCY)
395 #define lwsl_cx_latency(_c, ...) lwsl_cx(_c, LLL_LATENCY, __VA_ARGS__)
396 #else
397 #define lwsl_cx_latency(_c, ...) do {} while(0)
398 #endif
399 
400 #if (_LWS_ENABLED_LOGS & LLL_THREAD)
401 #define lwsl_cx_thread(_c, ...) lwsl_cx(_c, LLL_THREAD, __VA_ARGS__)
402 #else
403 #define lwsl_cx_thread(_c, ...) do {} while(0)
404 #endif
405 
406 #if (_LWS_ENABLED_LOGS & LLL_USER)
407 #define lwsl_cx_user(_c, ...) lwsl_cx(_c, LLL_USER, __VA_ARGS__)
408 #else
409 #define lwsl_cx_user(_c, ...) do {} while(0)
410 #endif
411 
412 #define lwsl_hexdump_cx_err(_c, ...) lwsl_hexdump_context(_c, LLL_ERR, __VA_ARGS__)
413 #define lwsl_hexdump_cx_warn(_c, ...) lwsl_hexdump_context(_c, LLL_WARN, __VA_ARGS__)
414 #define lwsl_hexdump_cx_notice(_c, ...) lwsl_hexdump_context(_c, LLL_NOTICE, __VA_ARGS__)
415 #define lwsl_hexdump_cx_info(_c, ...) lwsl_hexdump_context(_c, LLL_INFO, __VA_ARGS__)
416 #define lwsl_hexdump_cx_debug(_c, ...) lwsl_hexdump_context(_c, LLL_DEBUG, __VA_ARGS__)
417 
418 /*
419  * lws_vhost
420  */
421 
422 #if (_LWS_ENABLED_LOGS & LLL_ERR)
423 #define lwsl_vhost_err(_v, ...) lwsl_vhost(_v, LLL_ERR, __VA_ARGS__)
424 #else
425 #define lwsl_vhost_err(_v, ...) do {} while(0)
426 #endif
427 
428 #if (_LWS_ENABLED_LOGS & LLL_WARN)
429 #define lwsl_vhost_warn(_v, ...) lwsl_vhost(_v, LLL_WARN, __VA_ARGS__)
430 #else
431 #define lwsl_vhost_warn(_v, ...) do {} while(0)
432 #endif
433 
434 #if (_LWS_ENABLED_LOGS & LLL_NOTICE)
435 #define lwsl_vhost_notice(_v, ...) lwsl_vhost(_v, LLL_NOTICE, __VA_ARGS__)
436 #else
437 #define lwsl_vhost_notice(_v, ...) do {} while(0)
438 #endif
439 
440 #if (_LWS_ENABLED_LOGS & LLL_INFO)
441 #define lwsl_vhost_info(_v, ...) lwsl_vhost(_v, LLL_INFO, __VA_ARGS__)
442 #else
443 #define lwsl_vhost_info(_v, ...) do {} while(0)
444 #endif
445 
446 #if (_LWS_ENABLED_LOGS & LLL_DEBUG)
447 #define lwsl_vhost_debug(_v, ...) lwsl_vhost(_v, LLL_DEBUG, __VA_ARGS__)
448 #else
449 #define lwsl_vhost_debug(_v, ...) do {} while(0)
450 #endif
451 
452 #if (_LWS_ENABLED_LOGS & LLL_PARSER)
453 #define lwsl_vhost_parser(_v, ...) lwsl_vhost(_v, LLL_PARSER, __VA_ARGS__)
454 #else
455 #define lwsl_vhost_parser(_v, ...) do {} while(0)
456 #endif
457 
458 #if (_LWS_ENABLED_LOGS & LLL_HEADER)
459 #define lwsl_vhost_header(_v, ...) lwsl_vhost(_v, LLL_HEADER, __VA_ARGS__)
460 #else
461 #define lwsl_vhost_header(_v, ...) do {} while(0)
462 #endif
463 
464 #if (_LWS_ENABLED_LOGS & LLL_EXT)
465 #define lwsl_vhost_ext(_v, ...) lwsl_vhost(_v, LLL_EXT, __VA_ARGS__)
466 #else
467 #define lwsl_vhost_ext(_v, ...) do {} while(0)
468 #endif
469 
470 #if (_LWS_ENABLED_LOGS & LLL_CLIENT)
471 #define lwsl_vhost_client(_v, ...) lwsl_vhost(_v, LLL_CLIENT, __VA_ARGS__)
472 #else
473 #define lwsl_vhost_client(_v, ...) do {} while(0)
474 #endif
475 
476 #if (_LWS_ENABLED_LOGS & LLL_LATENCY)
477 #define lwsl_vhost_latency(_v, ...) lwsl_vhost(_v, LLL_LATENCY, __VA_ARGS__)
478 #else
479 #define lwsl_vhost_latency(_v, ...) do {} while(0)
480 #endif
481 
482 #if (_LWS_ENABLED_LOGS & LLL_THREAD)
483 #define lwsl_vhost_thread(_v, ...) lwsl_vhost(_v, LLL_THREAD, __VA_ARGS__)
484 #else
485 #define lwsl_vhost_thread(_v, ...) do {} while(0)
486 #endif
487 
488 #if (_LWS_ENABLED_LOGS & LLL_USER)
489 #define lwsl_vhost_user(_v, ...) lwsl_vhost(_v, LLL_USER, __VA_ARGS__)
490 #else
491 #define lwsl_vhost_user(_v, ...) do {} while(0)
492 #endif
493 
494 #define lwsl_hexdump_vhost_err(_v, ...) lwsl_hexdump_vhost(_v, LLL_ERR, __VA_ARGS__)
495 #define lwsl_hexdump_vhost_warn(_v, ...) lwsl_hexdump_vhost(_v, LLL_WARN, __VA_ARGS__)
496 #define lwsl_hexdump_vhost_notice(_v, ...) lwsl_hexdump_vhost(_v, LLL_NOTICE, __VA_ARGS__)
497 #define lwsl_hexdump_vhost_info(_v, ...) lwsl_hexdump_vhost(_v, LLL_INFO, __VA_ARGS__)
498 #define lwsl_hexdump_vhost_debug(_v, ...) lwsl_hexdump_vhost(_v, LLL_DEBUG, __VA_ARGS__)
499 
500 
501 /*
502  * lws_wsi
503  */
504 
505 #if (_LWS_ENABLED_LOGS & LLL_ERR)
506 #define lwsl_wsi_err(_w, ...) lwsl_wsi(_w, LLL_ERR, __VA_ARGS__)
507 #else
508 #define lwsl_wsi_err(_w, ...) do {} while(0)
509 #endif
510 
511 #if (_LWS_ENABLED_LOGS & LLL_WARN)
512 #define lwsl_wsi_warn(_w, ...) lwsl_wsi(_w, LLL_WARN, __VA_ARGS__)
513 #else
514 #define lwsl_wsi_warn(_w, ...) do {} while(0)
515 #endif
516 
517 #if (_LWS_ENABLED_LOGS & LLL_NOTICE)
518 #define lwsl_wsi_notice(_w, ...) lwsl_wsi(_w, LLL_NOTICE, __VA_ARGS__)
519 #else
520 #define lwsl_wsi_notice(_w, ...) do {} while(0)
521 #endif
522 
523 #if (_LWS_ENABLED_LOGS & LLL_INFO)
524 #define lwsl_wsi_info(_w, ...) lwsl_wsi(_w, LLL_INFO, __VA_ARGS__)
525 #else
526 #define lwsl_wsi_info(_w, ...) do {} while(0)
527 #endif
528 
529 #if (_LWS_ENABLED_LOGS & LLL_DEBUG)
530 #define lwsl_wsi_debug(_w, ...) lwsl_wsi(_w, LLL_DEBUG, __VA_ARGS__)
531 #else
532 #define lwsl_wsi_debug(_w, ...) do {} while(0)
533 #endif
534 
535 #if (_LWS_ENABLED_LOGS & LLL_PARSER)
536 #define lwsl_wsi_parser(_w, ...) lwsl_wsi(_w, LLL_PARSER, __VA_ARGS__)
537 #else
538 #define lwsl_wsi_parser(_w, ...) do {} while(0)
539 #endif
540 
541 #if (_LWS_ENABLED_LOGS & LLL_HEADER)
542 #define lwsl_wsi_header(_w, ...) lwsl_wsi(_w, LLL_HEADER, __VA_ARGS__)
543 #else
544 #define lwsl_wsi_header(_w, ...) do {} while(0)
545 #endif
546 
547 #if (_LWS_ENABLED_LOGS & LLL_EXT)
548 #define lwsl_wsi_ext(_w, ...) lwsl_wsi(_w, LLL_EXT, __VA_ARGS__)
549 #else
550 #define lwsl_wsi_ext(_w, ...) do {} while(0)
551 #endif
552 
553 #if (_LWS_ENABLED_LOGS & LLL_CLIENT)
554 #define lwsl_wsi_client(_w, ...) lwsl_wsi(_w, LLL_CLIENT, __VA_ARGS__)
555 #else
556 #define lwsl_wsi_client(_w, ...) do {} while(0)
557 #endif
558 
559 #if (_LWS_ENABLED_LOGS & LLL_LATENCY)
560 #define lwsl_wsi_latency(_w, ...) lwsl_wsi(_w, LLL_LATENCY, __VA_ARGS__)
561 #else
562 #define lwsl_wsi_latency(_w, ...) do {} while(0)
563 #endif
564 
565 #if (_LWS_ENABLED_LOGS & LLL_THREAD)
566 #define lwsl_wsi_thread(_w, ...) lwsl_wsi(_w, LLL_THREAD, __VA_ARGS__)
567 #else
568 #define lwsl_wsi_thread(_w, ...) do {} while(0)
569 #endif
570 
571 #if (_LWS_ENABLED_LOGS & LLL_USER)
572 #define lwsl_wsi_user(_w, ...) lwsl_wsi(_w, LLL_USER, __VA_ARGS__)
573 #else
574 #define lwsl_wsi_user(_w, ...) do {} while(0)
575 #endif
576 
577 #define lwsl_hexdump_wsi_err(_v, ...) lwsl_hexdump_wsi(_v, LLL_ERR, __VA_ARGS__)
578 #define lwsl_hexdump_wsi_warn(_v, ...) lwsl_hexdump_wsi(_v, LLL_WARN, __VA_ARGS__)
579 #define lwsl_hexdump_wsi_notice(_v, ...) lwsl_hexdump_wsi(_v, LLL_NOTICE, __VA_ARGS__)
580 #define lwsl_hexdump_wsi_info(_v, ...) lwsl_hexdump_wsi(_v, LLL_INFO, __VA_ARGS__)
581 #define lwsl_hexdump_wsi_debug(_v, ...) lwsl_hexdump_wsi(_v, LLL_DEBUG, __VA_ARGS__)
582 
583 
584 /*
585  * lwsl_ss
586  */
587 
588 #if (_LWS_ENABLED_LOGS & LLL_ERR)
589 #define lwsl_ss_err(_w, ...) lwsl_ss(_w, LLL_ERR, __VA_ARGS__)
590 #else
591 #define lwsl_ss_err(_w, ...) do {} while(0)
592 #endif
593 
594 #if (_LWS_ENABLED_LOGS & LLL_WARN)
595 #define lwsl_ss_warn(_w, ...) lwsl_ss(_w, LLL_WARN, __VA_ARGS__)
596 #else
597 #define lwsl_ss_warn(_w, ...) do {} while(0)
598 #endif
599 
600 #if (_LWS_ENABLED_LOGS & LLL_NOTICE)
601 #define lwsl_ss_notice(_w, ...) lwsl_ss(_w, LLL_NOTICE, __VA_ARGS__)
602 #else
603 #define lwsl_ss_notice(_w, ...) do {} while(0)
604 #endif
605 
606 #if (_LWS_ENABLED_LOGS & LLL_INFO)
607 #define lwsl_ss_info(_w, ...) lwsl_ss(_w, LLL_INFO, __VA_ARGS__)
608 #else
609 #define lwsl_ss_info(_w, ...) do {} while(0)
610 #endif
611 
612 #if (_LWS_ENABLED_LOGS & LLL_DEBUG)
613 #define lwsl_ss_debug(_w, ...) lwsl_ss(_w, LLL_DEBUG, __VA_ARGS__)
614 #else
615 #define lwsl_ss_debug(_w, ...) do {} while(0)
616 #endif
617 
618 #if (_LWS_ENABLED_LOGS & LLL_PARSER)
619 #define lwsl_ss_parser(_w, ...) lwsl_ss(_w, LLL_PARSER, __VA_ARGS__)
620 #else
621 #define lwsl_ss_parser(_w, ...) do {} while(0)
622 #endif
623 
624 #if (_LWS_ENABLED_LOGS & LLL_HEADER)
625 #define lwsl_ss_header(_w, ...) lwsl_ss(_w, LLL_HEADER, __VA_ARGS__)
626 #else
627 #define lwsl_ss_header(_w, ...) do {} while(0)
628 #endif
629 
630 #if (_LWS_ENABLED_LOGS & LLL_EXT)
631 #define lwsl_ss_ext(_w, ...) lwsl_ss(_w, LLL_EXT, __VA_ARGS__)
632 #else
633 #define lwsl_ss_ext(_w, ...) do {} while(0)
634 #endif
635 
636 #if (_LWS_ENABLED_LOGS & LLL_CLIENT)
637 #define lwsl_ss_client(_w, ...) lwsl_ss(_w, LLL_CLIENT, __VA_ARGS__)
638 #else
639 #define lwsl_ss_client(_w, ...) do {} while(0)
640 #endif
641 
642 #if (_LWS_ENABLED_LOGS & LLL_LATENCY)
643 #define lwsl_ss_latency(_w, ...) lwsl_ss(_w, LLL_LATENCY, __VA_ARGS__)
644 #else
645 #define lwsl_ss_latency(_w, ...) do {} while(0)
646 #endif
647 
648 #if (_LWS_ENABLED_LOGS & LLL_THREAD)
649 #define lwsl_ss_thread(_w, ...) lwsl_ss(_w, LLL_THREAD, __VA_ARGS__)
650 #else
651 #define lwsl_ss_thread(_w, ...) do {} while(0)
652 #endif
653 
654 #if (_LWS_ENABLED_LOGS & LLL_USER)
655 #define lwsl_ss_user(_w, ...) lwsl_ss(_w, LLL_USER, __VA_ARGS__)
656 #else
657 #define lwsl_ss_user(_w, ...) do {} while(0)
658 #endif
659 
660 #define lwsl_hexdump_ss_err(_v, ...) lwsl_hexdump_ss(_v, LLL_ERR, __VA_ARGS__)
661 #define lwsl_hexdump_ss_warn(_v, ...) lwsl_hexdump_ss(_v, LLL_WARN, __VA_ARGS__)
662 #define lwsl_hexdump_ss_notice(_v, ...) lwsl_hexdump_ss(_v, LLL_NOTICE, __VA_ARGS__)
663 #define lwsl_hexdump_ss_info(_v, ...) lwsl_hexdump_ss(_v, LLL_INFO, __VA_ARGS__)
664 #define lwsl_hexdump_ss_debug(_v, ...) lwsl_hexdump_ss(_v, LLL_DEBUG, __VA_ARGS__)
665 
666 
667 
678 LWS_VISIBLE LWS_EXTERN void
679 lwsl_hexdump_level(int level, const void *vbuf, size_t len);
680 
681 LWS_VISIBLE LWS_EXTERN void
682 lwsl_hexdump_level_cx(lws_log_cx_t *cx, lws_log_prepend_cx_t prep, void *obj,
683  int hexdump_level, const void *vbuf, size_t len);
684 
695 LWS_VISIBLE LWS_EXTERN void
696 lwsl_hexdump(const void *buf, size_t len);
697 
701 static LWS_INLINE int lws_is_be(void) {
702  const int probe = ~0xff;
703 
704  return *(const char *)&probe;
705 }
706 
726 LWS_VISIBLE LWS_EXTERN void
727 lws_set_log_level(int level, lws_log_emit_t log_emit_function);
728 
738 LWS_VISIBLE LWS_EXTERN void
739 lwsl_emit_syslog(int level, const char *line);
740 
754 LWS_VISIBLE LWS_EXTERN void
755 lwsl_emit_stderr(int level, const char *line);
756 
768 LWS_VISIBLE LWS_EXTERN void
769 lwsl_emit_stderr_notimestamp(int level, const char *line);
770 
780 LWS_VISIBLE LWS_EXTERN int
781 lwsl_visible(int level);
782 
783 struct lws;
784 
785 LWS_VISIBLE LWS_EXTERN const char *
786 lws_wsi_tag(struct lws *wsi);
787 
788 LWS_VISIBLE LWS_EXTERN void
789 lwsl_refcount_cx(lws_log_cx_t *cx, int _new);
790 
LWS_VISIBLE LWS_EXTERN void lwsl_hexdump_level(int level, const void *vbuf, size_t len)
LWS_VISIBLE LWS_EXTERN int lwsl_visible(int level)
LWS_VISIBLE LWS_EXTERN void lws_set_log_level(int level, lws_log_emit_t log_emit_function)
LWS_VISIBLE LWS_EXTERN int lwsl_timestamp(int level, char *p, size_t len)
LWS_VISIBLE LWS_EXTERN void lwsl_emit_stderr_notimestamp(int level, const char *line)
LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(const void *buf, size_t len)
LWS_VISIBLE LWS_EXTERN void lwsl_emit_stderr(int level, const char *line)
LWS_VISIBLE LWS_EXTERN void lwsl_emit_syslog(int level, const char *line)
Definition: lws-logs.h:80
uint32_t lll_flags
Definition: lws-logs.h:98
int32_t refcount
Definition: lws-logs.h:100
lws_log_prepend_cx_t prepend
Definition: lws-logs.h:89
void * stg
Definition: lws-logs.h:96
void * opaque
Definition: lws-logs.h:94
lws_log_use_cx_t refcount_cb
Definition: lws-logs.h:85
struct lws_log_cx * parent
Definition: lws-logs.h:92