diff --git a/include/libwebsockets/lws-context-vhost.h b/include/libwebsockets/lws-context-vhost.h index 929dd5791..b48a3200f 100644 --- a/include/libwebsockets/lws-context-vhost.h +++ b/include/libwebsockets/lws-context-vhost.h @@ -952,6 +952,13 @@ struct lws_context_creation_info { */ #endif + int default_loglevel; + /**< CONTEXT: 0 for LLL_USER, LLL_ERR, LLL_WARN, LLL_NOTICE enabled by default when + * using lws_cmdline_option_handle_builtin(), else set to the LLL_ flags you want + * to be the default before calling lws_cmdline_option_handle_builtin(). Your + * selected default loglevel can then be cleanly overridden using -d 1039 etc + * commandline switch */ + /* Add new things just above here ---^ * This is part of the ABI, don't needlessly break compatibility * diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c index 370d73a83..4fd5d561c 100644 --- a/lib/core/libwebsockets.c +++ b/lib/core/libwebsockets.c @@ -1632,7 +1632,8 @@ lws_cmdline_option_handle_builtin(int argc, const char **argv, struct lws_context_creation_info *info) { const char *p; - int n, m, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE; + int n, m, logs = info->default_loglevel ? info->default_loglevel : + LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE; #if defined(LWS_WITH_SYS_FAULT_INJECTION) uint64_t seed = (uint64_t)lws_now_usecs(); #endif