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