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_user(...) lwsl_hexdump_level(LLL_USER, __VA_ARGS__)
343#define lwsl_hexdump_err(...) lwsl_hexdump_level(LLL_ERR, __VA_ARGS__)
344#define lwsl_hexdump_warn(...) lwsl_hexdump_level(LLL_WARN, __VA_ARGS__)
345#define lwsl_hexdump_notice(...) lwsl_hexdump_level(LLL_NOTICE, __VA_ARGS__)
346#define lwsl_hexdump_info(...) lwsl_hexdump_level(LLL_INFO, __VA_ARGS__)
347#define lwsl_hexdump_debug(...) lwsl_hexdump_level(LLL_DEBUG, __VA_ARGS__)
348
349/*
350 * lws_context scope logs
351 */
352
353#if (_LWS_ENABLED_LOGS & LLL_ERR)
354#define lwsl_cx_err(_c, ...) lwsl_cx(_c, LLL_ERR, __VA_ARGS__)
355#else
356#define lwsl_cx_err(_c, ...) do {} while(0)
357#endif
358
359#if (_LWS_ENABLED_LOGS & LLL_WARN)
360#define lwsl_cx_warn(_c, ...) lwsl_cx(_c, LLL_WARN, __VA_ARGS__)
361#else
362#define lwsl_cx_warn(_c, ...) do {} while(0)
363#endif
364
365#if (_LWS_ENABLED_LOGS & LLL_NOTICE)
366#define lwsl_cx_notice(_c, ...) lwsl_cx(_c, LLL_NOTICE, __VA_ARGS__)
367#else
368#define lwsl_cx_notice(_c, ...) do {} while(0)
369#endif
370
371#if (_LWS_ENABLED_LOGS & LLL_INFO)
372#define lwsl_cx_info(_c, ...) lwsl_cx(_c, LLL_INFO, __VA_ARGS__)
373#else
374#define lwsl_cx_info(_c, ...) do {} while(0)
375#endif
376
377#if (_LWS_ENABLED_LOGS & LLL_DEBUG)
378#define lwsl_cx_debug(_c, ...) lwsl_cx(_c, LLL_DEBUG, __VA_ARGS__)
379#else
380#define lwsl_cx_debug(_c, ...) do {} while(0)
381#endif
382
383#if (_LWS_ENABLED_LOGS & LLL_PARSER)
384#define lwsl_cx_parser(_c, ...) lwsl_cx(_c, LLL_PARSER, __VA_ARGS__)
385#else
386#define lwsl_cx_parser(_c, ...) do {} while(0)
387#endif
388
389#if (_LWS_ENABLED_LOGS & LLL_HEADER)
390#define lwsl_cx_header(_c, ...) lwsl_cx(_c, LLL_HEADER, __VA_ARGS__)
391#else
392#define lwsl_cx_header(_c, ...) do {} while(0)
393#endif
394
395#if (_LWS_ENABLED_LOGS & LLL_EXT)
396#define lwsl_cx_ext(_c, ...) lwsl_cx(_c, LLL_EXT, __VA_ARGS__)
397#else
398#define lwsl_cx_ext(_c, ...) do {} while(0)
399#endif
400
401#if (_LWS_ENABLED_LOGS & LLL_CLIENT)
402#define lwsl_cx_client(_c, ...) lwsl_cx(_c, LLL_CLIENT, __VA_ARGS__)
403#else
404#define lwsl_cx_client(_c, ...) do {} while(0)
405#endif
406
407#if (_LWS_ENABLED_LOGS & LLL_LATENCY)
408#define lwsl_cx_latency(_c, ...) lwsl_cx(_c, LLL_LATENCY, __VA_ARGS__)
409#else
410#define lwsl_cx_latency(_c, ...) do {} while(0)
411#endif
412
413#if (_LWS_ENABLED_LOGS & LLL_THREAD)
414#define lwsl_cx_thread(_c, ...) lwsl_cx(_c, LLL_THREAD, __VA_ARGS__)
415#else
416#define lwsl_cx_thread(_c, ...) do {} while(0)
417#endif
418
419#if (_LWS_ENABLED_LOGS & LLL_USER)
420#define lwsl_cx_user(_c, ...) lwsl_cx(_c, LLL_USER, __VA_ARGS__)
421#else
422#define lwsl_cx_user(_c, ...) do {} while(0)
423#endif
424
425#define lwsl_hexdump_cx_err(_c, ...) lwsl_hexdump_context(_c, LLL_ERR, __VA_ARGS__)
426#define lwsl_hexdump_cx_warn(_c, ...) lwsl_hexdump_context(_c, LLL_WARN, __VA_ARGS__)
427#define lwsl_hexdump_cx_notice(_c, ...) lwsl_hexdump_context(_c, LLL_NOTICE, __VA_ARGS__)
428#define lwsl_hexdump_cx_info(_c, ...) lwsl_hexdump_context(_c, LLL_INFO, __VA_ARGS__)
429#define lwsl_hexdump_cx_debug(_c, ...) lwsl_hexdump_context(_c, LLL_DEBUG, __VA_ARGS__)
430
431/*
432 * lws_vhost
433 */
434
435#if (_LWS_ENABLED_LOGS & LLL_ERR)
436#define lwsl_vhost_err(_v, ...) lwsl_vhost(_v, LLL_ERR, __VA_ARGS__)
437#else
438#define lwsl_vhost_err(_v, ...) do {} while(0)
439#endif
440
441#if (_LWS_ENABLED_LOGS & LLL_WARN)
442#define lwsl_vhost_warn(_v, ...) lwsl_vhost(_v, LLL_WARN, __VA_ARGS__)
443#else
444#define lwsl_vhost_warn(_v, ...) do {} while(0)
445#endif
446
447#if (_LWS_ENABLED_LOGS & LLL_NOTICE)
448#define lwsl_vhost_notice(_v, ...) lwsl_vhost(_v, LLL_NOTICE, __VA_ARGS__)
449#else
450#define lwsl_vhost_notice(_v, ...) do {} while(0)
451#endif
452
453#if (_LWS_ENABLED_LOGS & LLL_INFO)
454#define lwsl_vhost_info(_v, ...) lwsl_vhost(_v, LLL_INFO, __VA_ARGS__)
455#else
456#define lwsl_vhost_info(_v, ...) do {} while(0)
457#endif
458
459#if (_LWS_ENABLED_LOGS & LLL_DEBUG)
460#define lwsl_vhost_debug(_v, ...) lwsl_vhost(_v, LLL_DEBUG, __VA_ARGS__)
461#else
462#define lwsl_vhost_debug(_v, ...) do {} while(0)
463#endif
464
465#if (_LWS_ENABLED_LOGS & LLL_PARSER)
466#define lwsl_vhost_parser(_v, ...) lwsl_vhost(_v, LLL_PARSER, __VA_ARGS__)
467#else
468#define lwsl_vhost_parser(_v, ...) do {} while(0)
469#endif
470
471#if (_LWS_ENABLED_LOGS & LLL_HEADER)
472#define lwsl_vhost_header(_v, ...) lwsl_vhost(_v, LLL_HEADER, __VA_ARGS__)
473#else
474#define lwsl_vhost_header(_v, ...) do {} while(0)
475#endif
476
477#if (_LWS_ENABLED_LOGS & LLL_EXT)
478#define lwsl_vhost_ext(_v, ...) lwsl_vhost(_v, LLL_EXT, __VA_ARGS__)
479#else
480#define lwsl_vhost_ext(_v, ...) do {} while(0)
481#endif
482
483#if (_LWS_ENABLED_LOGS & LLL_CLIENT)
484#define lwsl_vhost_client(_v, ...) lwsl_vhost(_v, LLL_CLIENT, __VA_ARGS__)
485#else
486#define lwsl_vhost_client(_v, ...) do {} while(0)
487#endif
488
489#if (_LWS_ENABLED_LOGS & LLL_LATENCY)
490#define lwsl_vhost_latency(_v, ...) lwsl_vhost(_v, LLL_LATENCY, __VA_ARGS__)
491#else
492#define lwsl_vhost_latency(_v, ...) do {} while(0)
493#endif
494
495#if (_LWS_ENABLED_LOGS & LLL_THREAD)
496#define lwsl_vhost_thread(_v, ...) lwsl_vhost(_v, LLL_THREAD, __VA_ARGS__)
497#else
498#define lwsl_vhost_thread(_v, ...) do {} while(0)
499#endif
500
501#if (_LWS_ENABLED_LOGS & LLL_USER)
502#define lwsl_vhost_user(_v, ...) lwsl_vhost(_v, LLL_USER, __VA_ARGS__)
503#else
504#define lwsl_vhost_user(_v, ...) do {} while(0)
505#endif
506
507#define lwsl_hexdump_vhost_err(_v, ...) lwsl_hexdump_vhost(_v, LLL_ERR, __VA_ARGS__)
508#define lwsl_hexdump_vhost_warn(_v, ...) lwsl_hexdump_vhost(_v, LLL_WARN, __VA_ARGS__)
509#define lwsl_hexdump_vhost_notice(_v, ...) lwsl_hexdump_vhost(_v, LLL_NOTICE, __VA_ARGS__)
510#define lwsl_hexdump_vhost_info(_v, ...) lwsl_hexdump_vhost(_v, LLL_INFO, __VA_ARGS__)
511#define lwsl_hexdump_vhost_debug(_v, ...) lwsl_hexdump_vhost(_v, LLL_DEBUG, __VA_ARGS__)
512
513
514/*
515 * lws_wsi
516 */
517
518#if (_LWS_ENABLED_LOGS & LLL_ERR)
519#define lwsl_wsi_err(_w, ...) lwsl_wsi(_w, LLL_ERR, __VA_ARGS__)
520#else
521#define lwsl_wsi_err(_w, ...) do {} while(0)
522#endif
523
524#if (_LWS_ENABLED_LOGS & LLL_WARN)
525#define lwsl_wsi_warn(_w, ...) lwsl_wsi(_w, LLL_WARN, __VA_ARGS__)
526#else
527#define lwsl_wsi_warn(_w, ...) do {} while(0)
528#endif
529
530#if (_LWS_ENABLED_LOGS & LLL_NOTICE)
531#define lwsl_wsi_notice(_w, ...) lwsl_wsi(_w, LLL_NOTICE, __VA_ARGS__)
532#else
533#define lwsl_wsi_notice(_w, ...) do {} while(0)
534#endif
535
536#if (_LWS_ENABLED_LOGS & LLL_INFO)
537#define lwsl_wsi_info(_w, ...) lwsl_wsi(_w, LLL_INFO, __VA_ARGS__)
538#else
539#define lwsl_wsi_info(_w, ...) do {} while(0)
540#endif
541
542#if (_LWS_ENABLED_LOGS & LLL_DEBUG)
543#define lwsl_wsi_debug(_w, ...) lwsl_wsi(_w, LLL_DEBUG, __VA_ARGS__)
544#else
545#define lwsl_wsi_debug(_w, ...) do {} while(0)
546#endif
547
548#if (_LWS_ENABLED_LOGS & LLL_PARSER)
549#define lwsl_wsi_parser(_w, ...) lwsl_wsi(_w, LLL_PARSER, __VA_ARGS__)
550#else
551#define lwsl_wsi_parser(_w, ...) do {} while(0)
552#endif
553
554#if (_LWS_ENABLED_LOGS & LLL_HEADER)
555#define lwsl_wsi_header(_w, ...) lwsl_wsi(_w, LLL_HEADER, __VA_ARGS__)
556#else
557#define lwsl_wsi_header(_w, ...) do {} while(0)
558#endif
559
560#if (_LWS_ENABLED_LOGS & LLL_EXT)
561#define lwsl_wsi_ext(_w, ...) lwsl_wsi(_w, LLL_EXT, __VA_ARGS__)
562#else
563#define lwsl_wsi_ext(_w, ...) do {} while(0)
564#endif
565
566#if (_LWS_ENABLED_LOGS & LLL_CLIENT)
567#define lwsl_wsi_client(_w, ...) lwsl_wsi(_w, LLL_CLIENT, __VA_ARGS__)
568#else
569#define lwsl_wsi_client(_w, ...) do {} while(0)
570#endif
571
572#if (_LWS_ENABLED_LOGS & LLL_LATENCY)
573#define lwsl_wsi_latency(_w, ...) lwsl_wsi(_w, LLL_LATENCY, __VA_ARGS__)
574#else
575#define lwsl_wsi_latency(_w, ...) do {} while(0)
576#endif
577
578#if (_LWS_ENABLED_LOGS & LLL_THREAD)
579#define lwsl_wsi_thread(_w, ...) lwsl_wsi(_w, LLL_THREAD, __VA_ARGS__)
580#else
581#define lwsl_wsi_thread(_w, ...) do {} while(0)
582#endif
583
584#if (_LWS_ENABLED_LOGS & LLL_USER)
585#define lwsl_wsi_user(_w, ...) lwsl_wsi(_w, LLL_USER, __VA_ARGS__)
586#else
587#define lwsl_wsi_user(_w, ...) do {} while(0)
588#endif
589
590#define lwsl_hexdump_wsi_err(_v, ...) lwsl_hexdump_wsi(_v, LLL_ERR, __VA_ARGS__)
591#define lwsl_hexdump_wsi_warn(_v, ...) lwsl_hexdump_wsi(_v, LLL_WARN, __VA_ARGS__)
592#define lwsl_hexdump_wsi_notice(_v, ...) lwsl_hexdump_wsi(_v, LLL_NOTICE, __VA_ARGS__)
593#define lwsl_hexdump_wsi_info(_v, ...) lwsl_hexdump_wsi(_v, LLL_INFO, __VA_ARGS__)
594#define lwsl_hexdump_wsi_debug(_v, ...) lwsl_hexdump_wsi(_v, LLL_DEBUG, __VA_ARGS__)
595#define lwsl_hexdump_wsi_user(_v, ...) lwsl_hexdump_wsi(_v, LLL_USER, __VA_ARGS__)
596
597
598
599/*
600 * lwsl_ss
601 */
602
603#if (_LWS_ENABLED_LOGS & LLL_ERR)
604#define lwsl_ss_err(_w, ...) lwsl_ss(_w, LLL_ERR, __VA_ARGS__)
605#else
606#define lwsl_ss_err(_w, ...) do {} while(0)
607#endif
608
609#if (_LWS_ENABLED_LOGS & LLL_WARN)
610#define lwsl_ss_warn(_w, ...) lwsl_ss(_w, LLL_WARN, __VA_ARGS__)
611#else
612#define lwsl_ss_warn(_w, ...) do {} while(0)
613#endif
614
615#if (_LWS_ENABLED_LOGS & LLL_NOTICE)
616#define lwsl_ss_notice(_w, ...) lwsl_ss(_w, LLL_NOTICE, __VA_ARGS__)
617#else
618#define lwsl_ss_notice(_w, ...) do {} while(0)
619#endif
620
621#if (_LWS_ENABLED_LOGS & LLL_INFO)
622#define lwsl_ss_info(_w, ...) lwsl_ss(_w, LLL_INFO, __VA_ARGS__)
623#else
624#define lwsl_ss_info(_w, ...) do {} while(0)
625#endif
626
627#if (_LWS_ENABLED_LOGS & LLL_DEBUG)
628#define lwsl_ss_debug(_w, ...) lwsl_ss(_w, LLL_DEBUG, __VA_ARGS__)
629#else
630#define lwsl_ss_debug(_w, ...) do {} while(0)
631#endif
632
633#if (_LWS_ENABLED_LOGS & LLL_PARSER)
634#define lwsl_ss_parser(_w, ...) lwsl_ss(_w, LLL_PARSER, __VA_ARGS__)
635#else
636#define lwsl_ss_parser(_w, ...) do {} while(0)
637#endif
638
639#if (_LWS_ENABLED_LOGS & LLL_HEADER)
640#define lwsl_ss_header(_w, ...) lwsl_ss(_w, LLL_HEADER, __VA_ARGS__)
641#else
642#define lwsl_ss_header(_w, ...) do {} while(0)
643#endif
644
645#if (_LWS_ENABLED_LOGS & LLL_EXT)
646#define lwsl_ss_ext(_w, ...) lwsl_ss(_w, LLL_EXT, __VA_ARGS__)
647#else
648#define lwsl_ss_ext(_w, ...) do {} while(0)
649#endif
650
651#if (_LWS_ENABLED_LOGS & LLL_CLIENT)
652#define lwsl_ss_client(_w, ...) lwsl_ss(_w, LLL_CLIENT, __VA_ARGS__)
653#else
654#define lwsl_ss_client(_w, ...) do {} while(0)
655#endif
656
657#if (_LWS_ENABLED_LOGS & LLL_LATENCY)
658#define lwsl_ss_latency(_w, ...) lwsl_ss(_w, LLL_LATENCY, __VA_ARGS__)
659#else
660#define lwsl_ss_latency(_w, ...) do {} while(0)
661#endif
662
663#if (_LWS_ENABLED_LOGS & LLL_THREAD)
664#define lwsl_ss_thread(_w, ...) lwsl_ss(_w, LLL_THREAD, __VA_ARGS__)
665#else
666#define lwsl_ss_thread(_w, ...) do {} while(0)
667#endif
668
669#if (_LWS_ENABLED_LOGS & LLL_USER)
670#define lwsl_ss_user(_w, ...) lwsl_ss(_w, LLL_USER, __VA_ARGS__)
671#else
672#define lwsl_ss_user(_w, ...) do {} while(0)
673#endif
674
675#define lwsl_hexdump_ss_err(_v, ...) lwsl_hexdump_ss(_v, LLL_ERR, __VA_ARGS__)
676#define lwsl_hexdump_ss_warn(_v, ...) lwsl_hexdump_ss(_v, LLL_WARN, __VA_ARGS__)
677#define lwsl_hexdump_ss_notice(_v, ...) lwsl_hexdump_ss(_v, LLL_NOTICE, __VA_ARGS__)
678#define lwsl_hexdump_ss_info(_v, ...) lwsl_hexdump_ss(_v, LLL_INFO, __VA_ARGS__)
679#define lwsl_hexdump_ss_debug(_v, ...) lwsl_hexdump_ss(_v, LLL_DEBUG, __VA_ARGS__)
680
681
682
694lwsl_hexdump_level(int level, const void *vbuf, size_t len);
695
698 int hexdump_level, const void *vbuf, size_t len);
699
711lwsl_hexdump(const void *buf, size_t len);
712
716static LWS_INLINE int lws_is_be(void) {
717 const int probe = ~0xff;
718
719 return *(const char *)&probe;
720}
721
742lws_set_log_level(int level, lws_log_emit_t log_emit_function);
743
754lwsl_emit_syslog(int level, const char *line);
755
770lwsl_emit_stderr(int level, const char *line);
771
784lwsl_emit_stderr_notimestamp(int level, const char *line);
785
796lwsl_visible(int level);
797
798struct lws;
799
800LWS_VISIBLE LWS_EXTERN const char *
801lws_wsi_tag(struct lws *wsi);
802
805
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)