libwebsockets
Lightweight C library for HTML5 websockets
Logging

Enumerations

enum  lws_log_levels {
  LLL_ERR = 1 << 0, LLL_WARN = 1 << 1, LLL_NOTICE = 1 << 2, LLL_INFO = 1 << 3,
  LLL_DEBUG = 1 << 4, LLL_PARSER = 1 << 5, LLL_HEADER = 1 << 6, LLL_EXT = 1 << 7,
  LLL_CLIENT = 1 << 8, LLL_LATENCY = 1 << 9, LLL_COUNT = 10
}
 

Functions

LWS_VISIBLE LWS_EXTERN void _lws_log (int filter, const char *format,...) LWS_FORMAT(2)
 
LWS_VISIBLE LWS_EXTERN void _lws_logv (int filter, const char *format, va_list vl)
 
LWS_VISIBLE LWS_EXTERN int lwsl_timestamp (int level, char *p, int len)
 
LWS_VISIBLE LWS_EXTERN void lwsl_hexdump (void *buf, size_t len)
 
LWS_VISIBLE LWS_EXTERN void lws_set_log_level (int level, void(*log_emit_function)(int level, const char *line))
 
LWS_VISIBLE LWS_EXTERN void lwsl_emit_syslog (int level, const char *line)
 

Detailed Description

Logging

Lws provides flexible and filterable logging facilities, which can be used inside lws and in user code.

Log categories may be individually filtered bitwise, and directed to built-in sinks for syslog-compatible logging, or a user-defined function.

Function Documentation

◆ lws_set_log_level()

LWS_VISIBLE LWS_EXTERN void lws_set_log_level ( int  level,
void(*)(int level, const char *line)  log_emit_function 
)

#include <lib/libwebsockets.h>

lws_set_log_level() - Set the logging bitfield

Parameters
levelOR together the LLL_ debug contexts you want output from
log_emit_functionNULL to leave it as it is, or a user-supplied function to perform log string emission instead of the default stderr one.

log level defaults to "err", "warn" and "notice" contexts enabled and emission on stderr.

◆ lwsl_emit_syslog()

LWS_VISIBLE LWS_EXTERN void lwsl_emit_syslog ( int  level,
const char *  line 
)

#include <lib/libwebsockets.h>

lwsl_emit_syslog() - helper log emit function writes to system log

Parameters
levelone of LLL_ log level indexes
linelog string

You use this by passing the function pointer to lws_set_log_level(), to set it as the log emit function, it is not called directly.

◆ lwsl_hexdump()

LWS_VISIBLE LWS_EXTERN void lwsl_hexdump ( void *  buf,
size_t  len 
)

#include <lib/libwebsockets.h>

lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only)

Parameters
bufbuffer start to dump
lenlength of buffer to dump

◆ lwsl_timestamp()

LWS_VISIBLE LWS_EXTERN int lwsl_timestamp ( int  level,
char *  p,
int  len 
)

#include <lib/libwebsockets.h>

lwsl_timestamp: generate logging timestamp string

Parameters
levellogging level
pchar * buffer to take timestamp
lenlength of p

returns length written in p