From 265a3f5089f650e55ac6857ffaf9d719ce8ef6f1 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Tue, 21 Oct 2025 15:38:16 +0200 Subject: [PATCH] Fix bootstrap problem with logger function. To intercept this with a log handler, it must be possible to set the log handler before any logging takes place. This logger_func / logger_user_data cannot be part of webui_core_t, because logging is already used in _webui_init() and _webui of type webui_core_t gets reset to 0 in _webui_init(). Signed-off-by: Hans Dijkema --- src/webui.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/webui.c b/src/webui.c index c37eb055f..4490318b0 100644 --- a/src/webui.c +++ b/src/webui.c @@ -444,8 +444,6 @@ typedef struct _webui_core_t { char* default_server_root_path; bool ui; char* custom_browser_folder_path; - void (*logger_func)(size_t level, const char* log, void* user_data); - void* logger_user_data; #ifdef WEBUI_TLS char* root_cert; char* root_key; @@ -466,6 +464,11 @@ typedef struct _webui_core_t { } _webui_core_t; +typedef struct _webui_log_t { + void (*logger_func)(size_t level, const char* log, void* user_data); + void* logger_user_data; +} _webui_log_t; + typedef struct _webui_recv_arg_t { _webui_window_t* win; void * ptr; @@ -694,6 +697,7 @@ static WEBUI_THREAD_MONITOR; // -- Heap ---------------------------- static _webui_core_t _webui; +static _webui_log_t _webui_log_data = { NULL, NULL }; static const char* webui_html_served = "Access Denied" @@ -710,7 +714,7 @@ static const char* webui_def_icon = "