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