diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index c1cea6f4..770cb24b 100755 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1244,6 +1244,11 @@ LWS_VISIBLE void lws_set_log_level(int level, lwsl_emit = func; } +LWS_VISIBLE int lwsl_visible(int level) +{ + return log_level & level; +} + LWS_VISIBLE int lws_is_ssl(struct lws *wsi) { diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 1aea763a..8af784c5 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -385,6 +385,18 @@ lws_set_log_level(int level, LWS_VISIBLE LWS_EXTERN void lwsl_emit_syslog(int level, const char *line); +/** + * lwsl_visible() - returns true if the log level should be printed + * + * \param level: one of LLL_ log level indexes + * + * This is useful if you have to do work to generate the log content, you + * can skip the work if the log level used to print it is not actually + * enabled at runtime. + */ +LWS_VISIBLE LWS_EXTERN int +lwsl_visible(int level); + ///@}