libwebsockets日志系统也是分等级的,如下:
cpp
#define LLL_ERR (1 << 0)
#define LLL_WARN (1 << 1)
#define LLL_NOTICE (1 << 2)
#define LLL_INFO (1 << 3)
#define LLL_DEBUG (1 << 4)
#define LLL_PARSER (1 << 5)
#define LLL_HEADER (1 << 6)
#define LLL_EXT (1 << 7)
#define LLL_CLIENT (1 << 8)
#define LLL_LATENCY (1 << 9)
#define LLL_USER (1 << 10)
#define LLL_THREAD (1 << 11)
#define LLL_COUNT (12) /* set to count of valid flags */
NORMAL masterɆ include/libwebsockets/lws-logs.h
要想打印日志,除了设置对应的等级外还需:
- 关闭宏定义LWS_WITH_NO_LOGS
- lws_set_log_level((1<<LLL_COUNT)-1, NULL)设置动态日志等级
cpp
/*
* Figure out which logs to build in or not
*/
#if defined(_DEBUG)
/*
* In DEBUG build, select all logs unless NO_LOGS
*/
#if defined(LWS_WITH_NO_LOGS)
#define _LWS_LINIT (LLL_ERR | LLL_USER)
#else
#define _LWS_LINIT ((1 << LLL_COUNT) - 1)
#endif
#else /* not _DEBUG */
#if defined(LWS_WITH_NO_LOGS)
#define _LWS_LINIT (LLL_ERR | LLL_USER)
#else
#define _LWS_LINIT (LLL_ERR | LLL_USER | LLL_WARN | LLL_NOTICE)
#endif
#endif /* _DEBUG */
cpp
lws_set_log_level((1<<LLL_COUNT)-1, NULL);