diff --git a/include/webui.h b/include/webui.h
index 2d5884a2f..ed45f791b 100644
--- a/include/webui.h
+++ b/include/webui.h
@@ -210,6 +210,12 @@ typedef struct webui_event_t {
char* cookies; // Client's full cookies
} webui_event_t;
+enum webui_logger_level {
+ WEBUI_LOGGER_LEVEL_DEBUG = 0, // 0. All logs with all details
+ WEBUI_LOGGER_LEVEL_INFO, // 1. Only general logs
+ WEBUI_LOGGER_LEVEL_ERROR, // 2. Only fatal error logs
+};
+
// -- Definitions ---------------------
/**
@@ -916,6 +922,17 @@ WEBUI_EXPORT bool webui_set_port(size_t window, size_t port);
*/
WEBUI_EXPORT size_t webui_get_free_port(void);
+/**
+ * @brief Set a custom logger function.
+ *
+ * @example
+ * void myLogger(size_t level, const char* log, void* user_data) {
+ * printf("myLogger (%d): %s", level, log);
+ * }
+ * webui_set_logger(myLogger, NULL);
+ */
+WEBUI_EXPORT void webui_set_logger(void (*func)(size_t level, const char* log, void* user_data), void *user_data);
+
/**
* @brief Control the WebUI behaviour. It's recommended to be called at the beginning.
*
diff --git a/src/webui.c b/src/webui.c
index d7e1c612a..a14d4be9e 100644
--- a/src/webui.c
+++ b/src/webui.c
@@ -435,6 +435,8 @@ typedef struct _webui_core_t {
char* default_server_root_path;
bool ui;
char* custom_browser_folder_path;
+ const void*(*logger_func)(size_t level, const char* log, void* user_data);
+ const void* logger_user_data;
#ifdef WEBUI_TLS
char* root_cert;
char* root_key;
@@ -696,12 +698,67 @@ static const char* webui_html_res_not_available = "
Resource N
"https://www.webui.me\">WebUI v" WEBUI_VERSION "";
static const char* webui_def_icon = ""; static const char* webui_def_icon_type = "image/svg+xml";
+// -- Logs ----------------------------
+
+static void _webui_log(webui_log_level_t level, const char *format, va_list args) {
+ if (_webui.logger_func == NULL) {
+ // Print log directly
+ if (level == WEBUI_LOGGER_LEVEL_ERROR) {
+ vfprintf(stderr, format, args);
+ } else {
+ vprintf(format, args);
+ }
+ } else {
+ // Pass log to user logger
+ va_list args_copy;
+ va_copy(args_copy, args);
+ int needed_size = vsnprintf(NULL, 0, format, args_copy);
+ va_end(args_copy);
+ if (needed_size < 0) {
+ _webui.logger_func(WEBUI_LOGGER_LEVEL_ERROR, "Log formatting error", _webui.logger_user_data);
+ return;
+ }
+ char *buffer = _webui_malloc(needed_size + 1);
+ if (buffer == NULL) {
+ _webui.logger_func(WEBUI_LOGGER_LEVEL_ERROR, "Memory allocation failed for log", _webui.logger_user_data);
+ return;
+ }
+ vsnprintf(buffer, needed_size + 1, format, args);
+ _webui.logger_func(level, buffer, _webui.logger_user_data);
+ _webui_free(buffer);
+ }
+}
+
+static void _webui_log_debug(const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ _webui_log(WEBUI_LOGGER_LEVEL_DEBUG, format, args);
+}
+
+static void _webui_log_info(const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ _webui_log(WEBUI_LOGGER_LEVEL_INFO, format, args);
+}
+
+static void _webui_log_error(const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ _webui_log(WEBUI_LOGGER_LEVEL_ERROR, format, args);
+}
+
+void webui_set_logger(void (*func)(size_t level, const char* log, void* user_data), void *user_data) {
+ _webui.logger_func = func;
+ _webui.logger_user_data = user_data;
+}
+
// -- Functions -----------------------
+
void webui_run_client(webui_event_t* e, const char* script) {
#ifdef WEBUI_LOG
- printf("[User] webui_run_client([%zu])\n", e->window);
- printf("[User] webui_run_client([%zu]) -> Script: [%s]\n", e->window, script);
+ _webui_log_info("[User] webui_run_client([%zu])\n", e->window);
+ _webui_log_info("[User] webui_run_client([%zu]) -> Script: [%s]\n", e->window, script);
#endif
// Initialization
@@ -731,8 +788,8 @@ void webui_run_client(webui_event_t* e, const char* script) {
void webui_run(size_t window, const char* script) {
#ifdef WEBUI_LOG
- printf("[User] webui_run([%zu])\n", window);
- printf("[User] webui_run([%zu]) -> Script: [%s]\n", window, script);
+ _webui_log_info("[User] webui_run([%zu])\n", window);
+ _webui_log_info("[User] webui_run([%zu]) -> Script: [%s]\n", window, script);
#endif
// Initialization
@@ -771,7 +828,7 @@ void webui_set_close_handler_wv(size_t window, bool(*close_handler)(size_t windo
_webui_window_t* win = _webui.wins[window];
#ifdef WEBUI_LOG
- printf("[User]webui_set_close_handler(%zu, %p)", window, close_handler);
+ _webui_log_info("[User]webui_set_close_handler(%zu, %p)", window, close_handler);
#endif
// Set the close handler
@@ -820,10 +877,10 @@ bool webui_script_client(webui_event_t* e, const char* script, size_t timeout,
char* buffer, size_t buffer_length) {
#ifdef WEBUI_LOG
- printf("[User] webui_script_client([%zu])\n", e->window);
- printf("[User] webui_script_client([%zu]) -> Script [%s] \n", e->window, script);
- printf("[User] webui_script_client([%zu]) -> Response Buffer @ 0x%p \n", e->window, buffer);
- printf("[User] webui_script_client([%zu]) -> Response Buffer Size %zu bytes \n", e->window, buffer_length);
+ _webui_log_info("[User] webui_script_client([%zu])\n", e->window);
+ _webui_log_info("[User] webui_script_client([%zu]) -> Script [%s] \n", e->window, script);
+ _webui_log_info("[User] webui_script_client([%zu]) -> Response Buffer @ 0x%p \n", e->window, buffer);
+ _webui_log_info("[User] webui_script_client([%zu]) -> Response Buffer Size %zu bytes \n", e->window, buffer_length);
#endif
// Initializing response buffer
@@ -898,11 +955,11 @@ bool webui_script_client(webui_event_t* e, const char* script, size_t timeout,
if (js_status) {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[User] webui_script -> Response found. User buffer len: %zu bytes \n",
_webui.run_userBufferLen[run_id]
);
- printf(
+ _webui_log(
"[User] webui_script -> Response found. User buffer data (ASCII): [%s] \n",
_webui.run_userBuffer[run_id]
);
@@ -912,7 +969,7 @@ bool webui_script_client(webui_event_t* e, const char* script, size_t timeout,
} else {
#ifdef WEBUI_LOG
- printf("[User] webui_script -> No Response is found. \n");
+ _webui_log_info("[User] webui_script -> No Response is found. \n");
#endif
}
@@ -923,7 +980,7 @@ bool webui_script(size_t window, const char* script, size_t timeout,
char* buffer, size_t buffer_length) {
#ifdef WEBUI_LOG
- printf("[User] webui_script([%zu])\n", window);
+ _webui_log_info("[User] webui_script([%zu])\n", window);
#endif
// Initialization
@@ -938,7 +995,7 @@ bool webui_script(size_t window, const char* script, size_t timeout,
// we can't send and receive from all clients
if (_webui.config.multi_client) {
#ifdef WEBUI_LOG
- printf("[User] webui_script() -> Multi-client mode is enabled, stop.\n");
+ _webui_log_info("[User] webui_script() -> Multi-client mode is enabled, stop.\n");
#endif
// Initializing response buffer
if (buffer_length > 0) {
@@ -976,7 +1033,7 @@ static uint32_t _webui_generate_random_uint32() {
size_t webui_new_window(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_new_window()\n");
+ _webui_log_info("[User] webui_new_window()\n");
#endif
// Create a new window
@@ -986,7 +1043,7 @@ size_t webui_new_window(void) {
size_t webui_new_window_id(size_t num) {
#ifdef WEBUI_LOG
- printf("[User] webui_new_window_id([%zu])\n", num);
+ _webui_log_info("[User] webui_new_window_id([%zu])\n", num);
#endif
// Initialization
@@ -1035,7 +1092,7 @@ size_t webui_new_window_id(size_t num) {
webui_bind(num, "__webui_core_api__", _webui_bridge_api_handler);
#ifdef WEBUI_LOG
- printf("[User] webui_new_window_id() -> New window #%zu @ 0x%p\n", num, win);
+ _webui_log_info("[User] webui_new_window_id() -> New window #%zu @ 0x%p\n", num, win);
#endif
return num;
@@ -1044,7 +1101,7 @@ size_t webui_new_window_id(size_t num) {
size_t webui_get_new_window_id(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_new_window_id()\n");
+ _webui_log_info("[User] webui_get_new_window_id()\n");
#endif
// Initialization
@@ -1067,7 +1124,7 @@ size_t webui_get_new_window_id(void) {
void webui_set_kiosk(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_kiosk([%zu])\n", window);
+ _webui_log_info("[User] webui_set_kiosk([%zu])\n", window);
#endif
// Initialization
@@ -1084,7 +1141,7 @@ void webui_set_kiosk(size_t window, bool status) {
void webui_set_custom_parameters(size_t window, char* params) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_custom_parameters([%zu], [%s])\n", window, params);
+ _webui_log_info("[User] webui_set_custom_parameters([%zu], [%s])\n", window, params);
#endif
// Initialization
@@ -1113,7 +1170,7 @@ void webui_set_custom_parameters(size_t window, char* params) {
void webui_set_resizable(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_resizable([%zu], [%d])\n", window, status);
+ _webui_log_info("[User] webui_set_resizable([%zu], [%d])\n", window, status);
#endif
// Initialization
@@ -1130,7 +1187,7 @@ void webui_set_resizable(size_t window, bool status) {
void webui_set_high_contrast(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_high_contrast([%zu], [%d])\n", window, status);
+ _webui_log_info("[User] webui_set_high_contrast([%zu], [%d])\n", window, status);
#endif
// Initialization
@@ -1147,7 +1204,7 @@ void webui_set_high_contrast(size_t window, bool status) {
bool webui_browser_exist(size_t browser) {
#ifdef WEBUI_LOG
- printf("[User] webui_browser_exist([%zu])\n", browser);
+ _webui_log_info("[User] webui_browser_exist([%zu])\n", browser);
#endif
return _webui_browser_exist(NULL, browser);
@@ -1156,7 +1213,7 @@ bool webui_browser_exist(size_t browser) {
bool webui_is_high_contrast(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_is_high_contrast()\n");
+ _webui_log_info("[User] webui_is_high_contrast()\n");
#endif
// Initialization
@@ -1200,7 +1257,7 @@ bool webui_is_high_contrast(void) {
#endif
#ifdef WEBUI_LOG
- printf("[User] webui_is_high_contrast() -> %d\n", is_enabled);
+ _webui_log_info("[User] webui_is_high_contrast() -> %d\n", is_enabled);
#endif
return is_enabled;
@@ -1209,7 +1266,7 @@ bool webui_is_high_contrast(void) {
void webui_close_client(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_close_client([%zu])\n", e->window);
+ _webui_log_info("[User] webui_close_client([%zu])\n", e->window);
#endif
// Initialization
@@ -1237,7 +1294,7 @@ void webui_close_client(webui_event_t* e) {
void webui_close(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_close([%zu])\n", window);
+ _webui_log_info("[User] webui_close([%zu])\n", window);
#endif
// Initialization
@@ -1277,7 +1334,7 @@ void webui_close(size_t window) {
void webui_destroy(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_destroy([%zu])\n", window);
+ _webui_log_info("[User] webui_destroy([%zu])\n", window);
#endif
// Initialization
@@ -1307,7 +1364,7 @@ void webui_destroy(size_t window) {
if (win->server_running) {
#ifdef WEBUI_LOG
- printf("[User] webui_destroy([%zu]) -> Forced close\n", window);
+ _webui_log_info("[User] webui_destroy([%zu]) -> Forced close\n", window);
#endif
// Forced close
@@ -1356,7 +1413,7 @@ void webui_destroy(size_t window) {
bool webui_is_shown(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_is_shown([%zu])\n", window);
+ _webui_log_info("[User] webui_is_shown([%zu])\n", window);
#endif
// Initialization
@@ -1373,7 +1430,7 @@ bool webui_is_shown(size_t window) {
void webui_set_icon(size_t window, const char* icon, const char* icon_type) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_icon([%zu], [%s], [%s])\n", window, icon, icon_type);
+ _webui_log_info("[User] webui_set_icon([%zu], [%s], [%s])\n", window, icon, icon_type);
#endif
// Initialization
@@ -1410,7 +1467,7 @@ void webui_set_icon(size_t window, const char* icon, const char* icon_type) {
void webui_navigate_client(webui_event_t* e, const char* url) {
#ifdef WEBUI_LOG
- printf("[User] webui_navigate_client([%zu], [%s])\n", e->window, url);
+ _webui_log_info("[User] webui_navigate_client([%zu], [%s])\n", e->window, url);
#endif
// Initialization
@@ -1442,7 +1499,7 @@ void webui_navigate_client(webui_event_t* e, const char* url) {
void webui_navigate(size_t window, const char* url) {
#ifdef WEBUI_LOG
- printf("[User] webui_navigate([%zu], [%s])\n", window, url);
+ _webui_log_info("[User] webui_navigate([%zu], [%s])\n", window, url);
#endif
// Initialization
@@ -1490,7 +1547,7 @@ void webui_navigate(size_t window, const char* url) {
void webui_clean(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_clean()\n");
+ _webui_log_info("[User] webui_clean()\n");
#endif
// Initialization
@@ -1503,7 +1560,7 @@ void webui_clean(void) {
void webui_delete_all_profiles(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_delete_all_profiles()\n");
+ _webui_log_info("[User] webui_delete_all_profiles()\n");
#endif
// Initialization
@@ -1520,7 +1577,7 @@ void webui_delete_all_profiles(void) {
static bool _webui_is_firefox_ini_profile_exist(const char* path, const char* profile_name) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_is_firefox_ini_profile_exist([%s], [%s])\n", path, profile_name);
+ _webui_log_debug("[Core]\t\t_webui_is_firefox_ini_profile_exist([%s], [%s])\n", path, profile_name);
#endif
// Parse home environments in the path
@@ -1546,7 +1603,7 @@ static bool _webui_is_firefox_ini_profile_exist(const char* path, const char* pr
#endif
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_is_firefox_ini_profile_exist() -> Opening [%s]\n", full_path);
+ _webui_log_debug("[Core]\t\t_webui_is_firefox_ini_profile_exist() -> Opening [%s]\n", full_path);
#endif
// Open
@@ -1564,7 +1621,7 @@ static bool _webui_is_firefox_ini_profile_exist(const char* path, const char* pr
while(fgets(line, sizeof(line), file)) {
if (strstr(line, target) != NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_is_firefox_ini_profile_exist() -> Target found\n");
+ _webui_log_debug("[Core]\t\t_webui_is_firefox_ini_profile_exist() -> Target found\n");
#endif
fclose(file);
return true;
@@ -1578,7 +1635,7 @@ static bool _webui_is_firefox_ini_profile_exist(const char* path, const char* pr
static void _webui_remove_firefox_profile_ini(const char* path, const char* profile_name) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_remove_firefox_profile_ini([%s], [%s])\n", path, profile_name);
+ _webui_log_debug("[Core]\t\t_webui_remove_firefox_profile_ini([%s], [%s])\n", path, profile_name);
#endif
// Parse home environments in the path
@@ -1604,7 +1661,7 @@ static void _webui_remove_firefox_profile_ini(const char* path, const char* prof
#endif
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_remove_firefox_profile_ini() -> Opening [%s]\n", full_path);
+ _webui_log_debug("[Core]\t\t_webui_remove_firefox_profile_ini() -> Opening [%s]\n", full_path);
#endif
// Open
@@ -1628,7 +1685,7 @@ static void _webui_remove_firefox_profile_ini(const char* path, const char* prof
if (!skip) {
if (strstr(buffer, target) != NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_remove_firefox_profile_ini() -> Target found\n");
+ _webui_log_debug("[Core]\t\t_webui_remove_firefox_profile_ini() -> Target found\n");
#endif
skip = true;
continue;
@@ -1641,7 +1698,7 @@ static void _webui_remove_firefox_profile_ini(const char* path, const char* prof
fclose(file);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_remove_firefox_profile_ini() -> Saving\n");
+ _webui_log_debug("[Core]\t\t_webui_remove_firefox_profile_ini() -> Saving\n");
#endif
// Save
@@ -1655,7 +1712,7 @@ static void _webui_remove_firefox_profile_ini(const char* path, const char* prof
void webui_delete_profile(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_delete_profile([%zu])\n", window);
+ _webui_log_info("[User] webui_delete_profile([%zu])\n", window);
#endif
// Initialization
@@ -1703,7 +1760,7 @@ void webui_delete_profile(size_t window) {
const char* webui_start_server(size_t window, const char* content) {
#ifdef WEBUI_LOG
- printf("[User] webui_start_server([%zu])\n", window);
+ _webui_log_info("[User] webui_start_server([%zu])\n", window);
#endif
if (_webui_is_empty(content))
@@ -1735,7 +1792,7 @@ const char* webui_start_server(size_t window, const char* content) {
bool webui_show_client(webui_event_t* e, const char* content) {
#ifdef WEBUI_LOG
- printf("[User] webui_show_client([%zu])\n", e->window);
+ _webui_log_info("[User] webui_show_client([%zu])\n", e->window);
#endif
// Initialization
@@ -1757,7 +1814,7 @@ bool webui_show_client(webui_event_t* e, const char* content) {
bool webui_show(size_t window, const char* content) {
#ifdef WEBUI_LOG
- printf("[User] webui_show([%zu])\n", window);
+ _webui_log_info("[User] webui_show([%zu])\n", window);
#endif
// Initialization
@@ -1779,7 +1836,7 @@ bool webui_show(size_t window, const char* content) {
bool webui_show_wv(size_t window, const char* content) {
#ifdef WEBUI_LOG
- printf("[User] webui_show_wv([%zu])\n", window);
+ _webui_log_info("[User] webui_show_wv([%zu])\n", window);
#endif
// Initialization
@@ -1801,7 +1858,7 @@ bool webui_show_wv(size_t window, const char* content) {
bool webui_show_browser(size_t window, const char* content, size_t browser) {
#ifdef WEBUI_LOG
- printf("[User] webui_show_browser([%zu], [%zu])\n", window, browser);
+ _webui_log_info("[User] webui_show_browser([%zu], [%zu])\n", window, browser);
#endif
// Initialization
@@ -1823,7 +1880,7 @@ bool webui_show_browser(size_t window, const char* content, size_t browser) {
void* webui_get_context(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_context()\n");
+ _webui_log_info("[User] webui_get_context()\n");
#endif
// Dereference
@@ -1836,7 +1893,7 @@ void* webui_get_context(webui_event_t* e) {
if (_webui_get_cb_index(win, e->element, &cb_index)) {
// Get context
#ifdef WEBUI_LOG
- printf("[User] webui_get_context() -> Found context at %p\n", win->cb_context[cb_index]);
+ _webui_log_info("[User] webui_get_context() -> Found context at %p\n", win->cb_context[cb_index]);
#endif
return win->cb_context[cb_index];
}
@@ -1847,9 +1904,9 @@ void* webui_get_context(webui_event_t* e) {
void webui_set_context(size_t window, const char* element, void* context) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_context([%zu])\n", window);
- printf("[User] webui_set_context() -> Element: [%s]\n", element);
- printf("[User] webui_set_context() -> Context: [%p]\n", context);
+ _webui_log_info("[User] webui_set_context([%zu])\n", window);
+ _webui_log_info("[User] webui_set_context() -> Element: [%s]\n", element);
+ _webui_log_info("[User] webui_set_context() -> Context: [%p]\n", context);
#endif
// Initialization
@@ -1869,14 +1926,14 @@ void webui_set_context(size_t window, const char* element, void* context) {
win->cb_context[cb_index] = context;
#ifdef WEBUI_LOG
- printf("[User] webui_set_context() -> Context saved at %zu\n", cb_index);
+ _webui_log_info("[User] webui_set_context() -> Context saved at %zu\n", cb_index);
#endif
}
size_t webui_bind(size_t window, const char* element, void(*func)(webui_event_t* e)) {
#ifdef WEBUI_LOG
- printf("[User] webui_bind([%zu])\n", window);
+ _webui_log_info("[User] webui_bind([%zu])\n", window);
#endif
// Initialization
@@ -1903,7 +1960,7 @@ size_t webui_bind(size_t window, const char* element, void(*func)(webui_event_t*
win->has_all_events = true;
win->cb[index] = func;
#ifdef WEBUI_LOG
- printf("[User] webui_bind() -> Save bind (all events) index %zu, address 0x%p\n", index, func);
+ _webui_log_info("[User] webui_bind() -> Save bind (all events) index %zu, address 0x%p\n", index, func);
#endif
}
return index;
@@ -1914,7 +1971,7 @@ size_t webui_bind(size_t window, const char* element, void(*func)(webui_event_t*
if (func != NULL) {
win->cb[index] = func;
#ifdef WEBUI_LOG
- printf("[User] webui_bind() -> Save bind index %zu, address 0x%p\n", index, func);
+ _webui_log_info("[User] webui_bind() -> Save bind index %zu, address 0x%p\n", index, func);
#endif
// Send to all connected clients the new binding ID
@@ -1938,7 +1995,7 @@ size_t webui_bind(size_t window, const char* element, void(*func)(webui_event_t*
size_t webui_get_best_browser(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_best_browser([%zu])\n", window);
+ _webui_log_info("[User] webui_get_best_browser([%zu])\n", window);
#endif
// Initialization
@@ -1955,7 +2012,7 @@ size_t webui_get_best_browser(size_t window) {
const char* webui_get_string_at(webui_event_t* e, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_string_at([%zu])\n", index);
+ _webui_log_info("[User] webui_get_string_at([%zu])\n", index);
#endif
// Initialization
@@ -1986,7 +2043,7 @@ const char* webui_get_string_at(webui_event_t* e, size_t index) {
size_t webui_get_count(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_count()\n");
+ _webui_log_info("[User] webui_get_count()\n");
#endif
// Initialization
@@ -2008,7 +2065,7 @@ size_t webui_get_count(webui_event_t* e) {
long long int webui_get_int_at(webui_event_t* e, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_int_at([%zu])\n", index);
+ _webui_log_info("[User] webui_get_int_at([%zu])\n", index);
#endif
// Initialization&Dereference
@@ -2034,7 +2091,7 @@ long long int webui_get_int_at(webui_event_t* e, size_t index) {
double webui_get_float_at(webui_event_t* e, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_float_at([%zu])\n", index);
+ _webui_log_info("[User] webui_get_float_at([%zu])\n", index);
#endif
// Initialization&Dereference
@@ -2060,7 +2117,7 @@ double webui_get_float_at(webui_event_t* e, size_t index) {
bool webui_get_bool_at(webui_event_t* e, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_bool_at([%zu])\n", index);
+ _webui_log_info("[User] webui_get_bool_at([%zu])\n", index);
#endif
// Initialization&Dereference
@@ -2082,7 +2139,7 @@ bool webui_get_bool_at(webui_event_t* e, size_t index) {
size_t webui_get_size_at(webui_event_t* e, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_size_at([%zu])\n", index);
+ _webui_log_info("[User] webui_get_size_at([%zu])\n", index);
#endif
// Initialization
@@ -2107,7 +2164,7 @@ size_t webui_get_size_at(webui_event_t* e, size_t index) {
const char* webui_get_string(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_string()\n");
+ _webui_log_info("[User] webui_get_string()\n");
#endif
return webui_get_string_at(e, 0);
@@ -2116,7 +2173,7 @@ const char* webui_get_string(webui_event_t* e) {
long long int webui_get_int(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_int()\n");
+ _webui_log_info("[User] webui_get_int()\n");
#endif
return webui_get_int_at(e, 0);
@@ -2125,7 +2182,7 @@ long long int webui_get_int(webui_event_t* e) {
double webui_get_float(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_float()\n");
+ _webui_log_info("[User] webui_get_float()\n");
#endif
return webui_get_float_at(e, 0);
@@ -2134,7 +2191,7 @@ double webui_get_float(webui_event_t* e) {
bool webui_get_bool(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_bool()\n");
+ _webui_log_info("[User] webui_get_bool()\n");
#endif
return webui_get_bool_at(e, 0);
@@ -2143,7 +2200,7 @@ bool webui_get_bool(webui_event_t* e) {
size_t webui_get_size(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_size()\n");
+ _webui_log_info("[User] webui_get_size()\n");
#endif
return webui_get_size_at(e, 0);
@@ -2152,7 +2209,7 @@ size_t webui_get_size(webui_event_t* e) {
void webui_return_int(webui_event_t* e, long long int n) {
#ifdef WEBUI_LOG
- printf("[User] webui_return_int([%lld])\n", n);
+ _webui_log_info("[User] webui_return_int([%lld])\n", n);
#endif
// Initialization
@@ -2191,7 +2248,7 @@ void webui_return_int(webui_event_t* e, long long int n) {
void webui_return_float(webui_event_t* e, double f) {
#ifdef WEBUI_LOG
- printf("[User] webui_return_float([%f])\n", f);
+ _webui_log_info("[User] webui_return_float([%f])\n", f);
#endif
// Initialization
@@ -2230,7 +2287,7 @@ void webui_return_float(webui_event_t* e, double f) {
void webui_return_string(webui_event_t* e, const char* s) {
#ifdef WEBUI_LOG
- printf("[User] webui_return_string([%s])\n", s);
+ _webui_log_info("[User] webui_return_string([%s])\n", s);
#endif
if (_webui_is_empty(s))
@@ -2272,7 +2329,7 @@ void webui_return_string(webui_event_t* e, const char* s) {
size_t webui_get_last_error_number() {
#ifdef WEBUI_LOG
- printf("[User] webui_get_last_error_number()\n");
+ _webui_log_info("[User] webui_get_last_error_number()\n");
#endif
// TODO: Add error code.
@@ -2282,7 +2339,7 @@ size_t webui_get_last_error_number() {
const char* webui_get_last_error_message() {
#ifdef WEBUI_LOG
- printf("[User] webui_get_last_error_message()\n");
+ _webui_log_info("[User] webui_get_last_error_message()\n");
#endif
// TODO: Add error message.
@@ -2292,7 +2349,7 @@ const char* webui_get_last_error_message() {
void webui_return_bool(webui_event_t* e, bool b) {
#ifdef WEBUI_LOG
- printf("[User] webui_return_bool([%d])\n", b);
+ _webui_log_info("[User] webui_return_bool([%d])\n", b);
#endif
// Initialization
@@ -2331,7 +2388,7 @@ void webui_return_bool(webui_event_t* e, bool b) {
size_t webui_get_parent_process_id(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_parent_process_id([%zu])\n", window);
+ _webui_log_info("[User] webui_get_parent_process_id([%zu])\n", window);
#endif
// Initialization
@@ -2352,7 +2409,7 @@ size_t webui_get_parent_process_id(size_t window) {
const char* webui_get_mime_type(const char* file) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_mime_type([%s])\n", file);
+ _webui_log_info("[User] webui_get_mime_type([%s])\n", file);
#endif
// Initialization
@@ -2364,7 +2421,7 @@ const char* webui_get_mime_type(const char* file) {
size_t webui_get_free_port(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_free_port()\n");
+ _webui_log_info("[User] webui_get_free_port()\n");
#endif
// Initialization
@@ -2376,7 +2433,7 @@ size_t webui_get_free_port(void) {
size_t webui_get_port(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_port([%zu])\n", window);
+ _webui_log_info("[User] webui_get_port([%zu])\n", window);
#endif
// Initialization
@@ -2394,7 +2451,7 @@ size_t webui_get_port(size_t window) {
static bool _webui_check_certificate(const char* certificate_pem, const char* private_key_pem) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_check_certificate()\n");
+ _webui_log_debug("[Core]\t\t_webui_check_certificate()\n");
#endif
OpenSSL_add_all_algorithms();
@@ -2417,7 +2474,7 @@ static bool _webui_check_certificate(const char* certificate_pem, const char* pr
X509 * cert = PEM_read_bio_X509(bio_cert, NULL, 0, NULL);
if (cert == NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_check_certificate() -> PEM_read_bio_X509 failed\n");
+ _webui_log_debug("[Core]\t\t_webui_check_certificate() -> PEM_read_bio_X509 failed\n");
#endif
BIO_free_all(bio_cert);
X509_free(cert);
@@ -2428,7 +2485,7 @@ static bool _webui_check_certificate(const char* certificate_pem, const char* pr
// Use certificate
if (SSL_CTX_use_certificate(ctx, cert) <= 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_check_certificate() -> SSL_CTX_use_certificate "
+ _webui_log_debug("[Core]\t\t_webui_check_certificate() -> SSL_CTX_use_certificate "
"failed\n");
#endif
BIO_free_all(bio_cert);
@@ -2442,7 +2499,7 @@ static bool _webui_check_certificate(const char* certificate_pem, const char* pr
EVP_PKEY * private_key = PEM_read_bio_PrivateKey(bio_key, NULL, 0, NULL);
if (private_key == NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_check_certificate() -> PEM_read_bio_PrivateKey "
+ _webui_log_debug("[Core]\t\t_webui_check_certificate() -> PEM_read_bio_PrivateKey "
"failed\n");
#endif
EVP_PKEY_free(private_key);
@@ -2457,7 +2514,7 @@ static bool _webui_check_certificate(const char* certificate_pem, const char* pr
// Use key
if (SSL_CTX_use_PrivateKey(ctx, private_key) <= 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_check_certificate() -> SSL_CTX_use_PrivateKey "
+ _webui_log_debug("[Core]\t\t_webui_check_certificate() -> SSL_CTX_use_PrivateKey "
"failed\n");
#endif
EVP_PKEY_free(private_key);
@@ -2485,7 +2542,7 @@ bool webui_set_tls_certificate(const char* certificate_pem, const char* private_
(void)certificate_pem;
(void)private_key_pem;
#ifdef WEBUI_LOG
- printf("[User] webui_set_tls_certificate()\n");
+ _webui_log_info("[User] webui_set_tls_certificate()\n");
#endif
// Initialization
@@ -2506,7 +2563,7 @@ bool webui_set_tls_certificate(const char* certificate_pem, const char* private_
unsigned long err = ERR_get_error();
char err_buf[1024];
ERR_error_string_n(err, err_buf, sizeof(err_buf));
- printf("[User] webui_set_tls_certificate() -> Invalid certificate:\n%s\n", err_buf);
+ _webui_log_info("[User] webui_set_tls_certificate() -> Invalid certificate:\n%s\n", err_buf);
#endif
return false;
}
@@ -2526,9 +2583,9 @@ bool webui_set_tls_certificate(const char* certificate_pem, const char* private_
_webui.ssl_key = ssl_key;
#ifdef WEBUI_LOG
- printf("[User] webui_set_tls_certificate() -> SSL/TLS Certificate:\n");
- printf("%s\n", (const char*)_webui.ssl_cert);
- printf("%s\n", (const char*)_webui.ssl_key);
+ _webui_log_info("[User] webui_set_tls_certificate() -> SSL/TLS Certificate:\n");
+ _webui_log("%s\n", (const char*)_webui.ssl_cert);
+ _webui_log("%s\n", (const char*)_webui.ssl_key);
#endif
return true;
@@ -2544,7 +2601,7 @@ bool webui_set_tls_certificate(const char* certificate_pem, const char* private_
void webui_set_config(webui_config option, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_config([%d], [%d])\n", option, status);
+ _webui_log_info("[User] webui_config([%d], [%d])\n", option, status);
#endif
// Initialization
@@ -2579,7 +2636,7 @@ void webui_set_config(webui_config option, bool status) {
break;
#ifdef WEBUI_LOG
default:
- printf("[User] webui_config -> Unknown option [%d]\n", option);
+ _webui_log_info("[User] webui_config -> Unknown option [%d]\n", option);
break;
#endif
}
@@ -2588,7 +2645,7 @@ void webui_set_config(webui_config option, bool status) {
void webui_set_frameless(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_frameless([%zu], [%d])\n", window, status);
+ _webui_log_info("[User] webui_set_frameless([%zu], [%d])\n", window, status);
#endif
// Initialization
@@ -2605,7 +2662,7 @@ void webui_set_frameless(size_t window, bool status) {
void webui_set_transparent(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_transparent([%zu], [%d])\n", window, status);
+ _webui_log_info("[User] webui_set_transparent([%zu], [%d])\n", window, status);
#endif
// Initialization
@@ -2621,7 +2678,7 @@ void webui_set_transparent(size_t window, bool status) {
void webui_set_event_blocking(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_event_blocking([%zu], [%d])\n", window, status);
+ _webui_log_info("[User] webui_set_event_blocking([%zu], [%d])\n", window, status);
#endif
// Initialization
@@ -2638,7 +2695,7 @@ void webui_set_event_blocking(size_t window, bool status) {
bool webui_set_port(size_t window, size_t port) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_port([%zu], [%zu])\n", window, port);
+ _webui_log_info("[User] webui_set_port([%zu], [%zu])\n", window, port);
#endif
// Initialization
@@ -2659,7 +2716,7 @@ bool webui_set_port(size_t window, size_t port) {
size_t webui_get_child_process_id(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_child_process_id([%zu])\n", window);
+ _webui_log_info("[User] webui_get_child_process_id([%zu])\n", window);
#endif
// Initialization
@@ -2676,7 +2733,7 @@ size_t webui_get_child_process_id(size_t window) {
void* webui_win32_get_hwnd(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_win32_get_hwnd([%zu])\n", window);
+ _webui_log_info("[User] webui_win32_get_hwnd([%zu])\n", window);
#endif
// Initialization
@@ -2722,7 +2779,7 @@ void* webui_win32_get_hwnd(size_t window) {
void webui_set_hide(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_hide(%zu, %d)\n", window, status);
+ _webui_log_info("[User] webui_set_hide(%zu, %d)\n", window, status);
#endif
// Initialization
@@ -2739,7 +2796,7 @@ void webui_set_hide(size_t window, bool status) {
void webui_minimize(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_minimize(%zu)\n", window);
+ _webui_log_info("[User] webui_minimize(%zu)\n", window);
#endif
// Initialization
@@ -2758,7 +2815,7 @@ void webui_minimize(size_t window) {
void webui_maximize(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_minimize(%zu)\n", window);
+ _webui_log_info("[User] webui_minimize(%zu)\n", window);
#endif
// Initialization
@@ -2777,7 +2834,7 @@ void webui_maximize(size_t window) {
void webui_set_size(size_t window, unsigned int width, unsigned int height) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_size(%zu, %u, %u)\n", window, width, height);
+ _webui_log_info("[User] webui_set_size(%zu, %u, %u)\n", window, width, height);
#endif
// Initialization
@@ -2834,7 +2891,7 @@ void webui_set_size(size_t window, unsigned int width, unsigned int height) {
void webui_set_minimum_size(size_t window, unsigned int width, unsigned int height) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_minimum_size(%zu, %u, %u)\n", window, width, height);
+ _webui_log_info("[User] webui_set_minimum_size(%zu, %u, %u)\n", window, width, height);
#endif
// Initialization
@@ -2860,7 +2917,7 @@ void webui_set_minimum_size(size_t window, unsigned int width, unsigned int heig
void webui_set_position(size_t window, unsigned int x, unsigned int y) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_position(%zu, %u, %u)\n", window, x, y);
+ _webui_log_info("[User] webui_set_position(%zu, %u, %u)\n", window, x, y);
#endif
// Initialization
@@ -2922,7 +2979,7 @@ void webui_set_position(size_t window, unsigned int x, unsigned int y) {
void webui_set_center(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_center(%zu)\n", window);
+ _webui_log_info("[User] webui_set_center(%zu)\n", window);
#endif
// Initialization
@@ -2963,7 +3020,7 @@ void webui_set_center(size_t window) {
#endif
#ifdef WEBUI_LOG
- printf("[User] webui_set_center() -> Screen dimensions: width=%u, height=%u\n", screen_width, screen_height);
+ _webui_log_info("[User] webui_set_center() -> Screen dimensions: width=%u, height=%u\n", screen_width, screen_height);
#endif
// Default window dimensions
@@ -2976,8 +3033,8 @@ void webui_set_center(size_t window) {
unsigned int center_x = (screen_width - win->width) / 2;
unsigned int center_y = (screen_height - win->height) / 2;
#ifdef WEBUI_LOG
- printf("[User] webui_set_center() -> Window dimensions: width=%u, height=%u\n", win->width, win->height);
- printf("[User] webui_set_center() -> Calculated center positions: x=%u, y=%u\n", center_x, center_y);
+ _webui_log_info("[User] webui_set_center() -> Window dimensions: width=%u, height=%u\n", win->width, win->height);
+ _webui_log_info("[User] webui_set_center() -> Calculated center positions: x=%u, y=%u\n", center_x, center_y);
#endif
// Set window center position
webui_set_position(window, center_x, center_y);
@@ -2988,7 +3045,7 @@ void webui_set_center(size_t window) {
void webui_set_profile(size_t window, const char* name, const char* path) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_profile([%s], [%s])\n", name, path);
+ _webui_log_info("[User] webui_set_profile([%s], [%s])\n", name, path);
#endif
// Initialization
@@ -3037,7 +3094,7 @@ void webui_set_profile(size_t window, const char* name, const char* path) {
void webui_set_proxy(size_t window, const char* proxy_server) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_proxy([%s])\n", proxy_server);
+ _webui_log_info("[User] webui_set_proxy([%s])\n", proxy_server);
#endif
// Initialization
@@ -3078,7 +3135,7 @@ void webui_set_proxy(size_t window, const char* proxy_server) {
void webui_open_url(const char* url) {
#ifdef WEBUI_LOG
- printf("[User] webui_open_url([%s])\n", url);
+ _webui_log_info("[User] webui_open_url([%s])\n", url);
#endif
// Initialization
@@ -3090,7 +3147,7 @@ void webui_open_url(const char* url) {
const char* webui_get_url(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_get_url([%zu])\n", window);
+ _webui_log_info("[User] webui_get_url([%zu])\n", window);
#endif
// Initialization
@@ -3126,7 +3183,7 @@ const char* webui_get_url(size_t window) {
void webui_set_public(size_t window, bool status) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_public([%zu])\n", window);
+ _webui_log_info("[User] webui_set_public([%zu])\n", window);
#endif
// Initialization
@@ -3143,7 +3200,7 @@ void webui_set_public(size_t window, bool status) {
void webui_send_raw_client(webui_event_t* e, const char* function, const void* raw, size_t size) {
#ifdef WEBUI_LOG
- printf("[User] webui_send_raw_client(%zu bytes)\n", size);
+ _webui_log_info("[User] webui_send_raw_client(%zu bytes)\n", size);
#endif
if ((size < 1) || (_webui_strlen(function) < 1) || (raw == NULL))
@@ -3193,7 +3250,7 @@ void webui_send_raw_client(webui_event_t* e, const char* function, const void* r
void webui_send_raw(size_t window, const char* function, const void * raw, size_t size) {
#ifdef WEBUI_LOG
- printf("[User] webui_send_raw(%zu bytes)\n", size);
+ _webui_log_info("[User] webui_send_raw(%zu bytes)\n", size);
#endif
if ((size < 1) || (_webui_strlen(function) < 1) || (raw == NULL))
@@ -3240,7 +3297,7 @@ void webui_send_raw(size_t window, const char* function, const void * raw, size_
char* webui_encode(const char* str) {
#ifdef WEBUI_LOG
- printf("[User] webui_encode()\n");
+ _webui_log_info("[User] webui_encode()\n");
#endif
// Initialization
@@ -3253,7 +3310,7 @@ char* webui_encode(const char* str) {
return NULL;
#ifdef WEBUI_LOG
- printf("[User] webui_encode() -> Text: [%s]\n", str);
+ _webui_log_info("[User] webui_encode() -> Text: [%s]\n", str);
#endif
size_t buf_len = (((len + 2) / 3) * 4) + 8;
@@ -3265,14 +3322,14 @@ char* webui_encode(const char* str) {
// Failed
#ifdef WEBUI_LOG
- printf("[User] webui_encode() -> Failed (%d).\n", ret);
+ _webui_log_info("[User] webui_encode() -> Failed (%d).\n", ret);
#endif
_webui_free_mem((void*)buf);
return NULL;
}
#ifdef WEBUI_LOG
- printf("[User] webui_encode() -> Encoded: [%s]\n", buf);
+ _webui_log_info("[User] webui_encode() -> Encoded: [%s]\n", buf);
#endif
// Success
@@ -3282,7 +3339,7 @@ char* webui_encode(const char* str) {
char* webui_decode(const char* str) {
#ifdef WEBUI_LOG
- printf("[User] webui_decode()\n");
+ _webui_log_info("[User] webui_decode()\n");
#endif
// Initialization
@@ -3295,7 +3352,7 @@ char* webui_decode(const char* str) {
return NULL;
#ifdef WEBUI_LOG
- printf("[User] webui_decode() -> Encoded: [%s]\n", str);
+ _webui_log_info("[User] webui_decode() -> Encoded: [%s]\n", str);
#endif
size_t buf_len = (((len + 2) / 3) * 4) + 8;
@@ -3307,14 +3364,14 @@ char* webui_decode(const char* str) {
// Failed
#ifdef WEBUI_LOG
- printf("[User] webui_decode() -> Failed (%d).\n", ret);
+ _webui_log_info("[User] webui_decode() -> Failed (%d).\n", ret);
#endif
_webui_free_mem((void*)buf);
return NULL;
}
#ifdef WEBUI_LOG
- printf("[User] webui_decode() -> Decoded: [%s]\n", buf);
+ _webui_log_info("[User] webui_decode() -> Decoded: [%s]\n", buf);
#endif
// Success
@@ -3324,7 +3381,7 @@ char* webui_decode(const char* str) {
void webui_free(void * ptr) {
#ifdef WEBUI_LOG
- printf("[User] webui_free([0x%p])\n", ptr);
+ _webui_log_info("[User] webui_free([0x%p])\n", ptr);
#endif
// Initialization
@@ -3338,8 +3395,8 @@ void webui_free(void * ptr) {
void webui_memcpy(void* dest, void* src, size_t count) {
#ifdef WEBUI_LOG
- printf("[User] webui_memcpy()\n");
- printf("[User] webui_memcpy() -> Copying %zu bytes from [%p] to [%p]\n", count, src, dest);
+ _webui_log_info("[User] webui_memcpy()\n");
+ _webui_log_info("[User] webui_memcpy() -> Copying %zu bytes from [%p] to [%p]\n", count, src, dest);
#endif
// Initialization
@@ -3353,7 +3410,7 @@ void webui_memcpy(void* dest, void* src, size_t count) {
void * webui_malloc(size_t size) {
#ifdef WEBUI_LOG
- printf("[User] webui_malloc(%zu bytes)\n", size);
+ _webui_log_info("[User] webui_malloc(%zu bytes)\n", size);
#endif
// Initialization
@@ -3367,7 +3424,7 @@ void * webui_malloc(size_t size) {
void webui_exit(void) {
#ifdef WEBUI_LOG
- printf("[User] webui_exit()\n");
+ _webui_log_info("[User] webui_exit()\n");
#endif
// Initialization
@@ -3437,7 +3494,7 @@ void webui_exit(void) {
void webui_wait(void) {
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait()\n");
+ _webui_log("[Loop] webui_wait()\n");
#endif
// Initialization
@@ -3453,13 +3510,13 @@ void webui_wait(void) {
if (!_webui.ui) {
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> No window is found. Stop\n");
+ _webui_log("[Loop] webui_wait() -> No window is found. Stop\n");
#endif
return;
}
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Waiting (Timeout in %zu seconds)\n",
+ _webui_log("[Loop] webui_wait() -> Waiting (Timeout in %zu seconds)\n",
_webui.startup_timeout);
#endif
@@ -3469,7 +3526,7 @@ void webui_wait(void) {
} else {
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Infinite waiting\n");
+ _webui_log("[Loop] webui_wait() -> Infinite waiting\n");
#endif
// The mutex conditional signal will
@@ -3483,7 +3540,7 @@ void webui_wait(void) {
// Windows Web browser main loop
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Windows web browser loop\n");
+ _webui_log("[Loop] webui_wait() -> Windows web browser loop\n");
#endif
_webui.is_browser_main_run = true;
@@ -3495,7 +3552,7 @@ void webui_wait(void) {
// Windows WebView main loop
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Windows WebView loop\n");
+ _webui_log("[Loop] webui_wait() -> Windows WebView loop\n");
#endif
_webui_mutex_lock(&_webui.mutex_wait);
@@ -3506,7 +3563,7 @@ void webui_wait(void) {
// Linux Web browser main loop
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Linux web browser loop\n");
+ _webui_log("[Loop] webui_wait() -> Linux web browser loop\n");
#endif
_webui.is_browser_main_run = true;
@@ -3518,7 +3575,7 @@ void webui_wait(void) {
// Linux WebView main loop
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Linux WebView loop\n");
+ _webui_log("[Loop] webui_wait() -> Linux WebView loop\n");
#endif
_webui.is_gtk_main_run = true;
@@ -3533,7 +3590,7 @@ void webui_wait(void) {
// macOS Web browser main loop
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> macOS web browser loop\n");
+ _webui_log("[Loop] webui_wait() -> macOS web browser loop\n");
#endif
_webui.is_browser_main_run = true;
@@ -3545,7 +3602,7 @@ void webui_wait(void) {
// macOS WebView main loop
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> macOS WebView loop\n");
+ _webui_log("[Loop] webui_wait() -> macOS WebView loop\n");
#endif
_webui.is_wkwebview_main_run = true;
@@ -3558,7 +3615,7 @@ void webui_wait(void) {
#endif
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Cleaning\n");
+ _webui_log("[Loop] webui_wait() -> Cleaning\n");
#endif
// Clean
@@ -3623,7 +3680,7 @@ void webui_wait(void) {
#endif
#ifdef WEBUI_LOG
- printf("[Loop] webui_wait() -> Main loop exit successfully\n");
+ _webui_log("[Loop] webui_wait() -> Main loop exit successfully\n");
#endif
_webui_mutex_unlock(&_webui.mutex_wait);
@@ -3632,7 +3689,7 @@ void webui_wait(void) {
void webui_set_timeout(size_t second) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_timeout([%zu])\n", second);
+ _webui_log_info("[User] webui_set_timeout([%zu])\n", second);
#endif
// Initialization
@@ -3649,7 +3706,7 @@ void webui_set_timeout(size_t second) {
void webui_set_runtime(size_t window, size_t runtime) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_runtime([%zu], [%zu])\n", window, runtime);
+ _webui_log_info("[User] webui_set_runtime([%zu], [%zu])\n", window, runtime);
#endif
// Initialization
@@ -3669,7 +3726,7 @@ void webui_set_runtime(size_t window, size_t runtime) {
void webui_set_browser_folder(const char* path) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_browser_folder([%s])\n", path);
+ _webui_log_info("[User] webui_set_browser_folder([%s])\n", path);
#endif
// Initialization
@@ -3689,7 +3746,7 @@ void webui_set_browser_folder(const char* path) {
bool webui_set_root_folder(size_t window, const char* path) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_root_folder([%zu], [%s])\n", window, path);
+ _webui_log_info("[User] webui_set_root_folder([%zu], [%s])\n", window, path);
#endif
// Initialization
@@ -3718,13 +3775,13 @@ bool webui_set_root_folder(size_t window, const char* path) {
WEBUI_SN_PRINTF_DYN(win->server_root_path, WEBUI_MAX_PATH, "%s", WEBUI_DEFAULT_PATH);
#ifdef WEBUI_LOG
- printf("[User] webui_set_root_folder() -> failed\n");
+ _webui_log_info("[User] webui_set_root_folder() -> failed\n");
#endif
return false;
}
#ifdef WEBUI_LOG
- printf("[User] webui_set_root_folder() -> Success\n");
+ _webui_log_info("[User] webui_set_root_folder() -> Success\n");
#endif
WEBUI_SN_PRINTF_DYN(win->server_root_path, WEBUI_MAX_PATH, "%s", path);
return true;
@@ -3733,7 +3790,7 @@ bool webui_set_root_folder(size_t window, const char* path) {
bool webui_set_default_root_folder(const char* path) {
#ifdef WEBUI_LOG
- printf("[User] webui_set_default_root_folder([%s])\n", path);
+ _webui_log_info("[User] webui_set_default_root_folder([%s])\n", path);
#endif
// Initialization
@@ -3745,13 +3802,13 @@ bool webui_set_default_root_folder(const char* path) {
_webui.default_server_root_path[0] = '\0';
#ifdef WEBUI_LOG
- printf("[User] webui_set_default_root_folder() -> failed\n");
+ _webui_log_info("[User] webui_set_default_root_folder() -> failed\n");
#endif
return false;
}
#ifdef WEBUI_LOG
- printf("[User] webui_set_default_root_folder() -> Success\n");
+ _webui_log_info("[User] webui_set_default_root_folder() -> Success\n");
#endif
WEBUI_SN_PRINTF_DYN(_webui.default_server_root_path, WEBUI_MAX_PATH, "%s", path);
@@ -3771,7 +3828,7 @@ bool webui_set_default_root_folder(const char* path) {
static void _webui_interface_bind_handler_all(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interface_bind_handler_all()\n");
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler_all()\n");
#endif
// Initialization
@@ -3789,18 +3846,18 @@ static void _webui_interface_bind_handler_all(webui_event_t* e) {
if (exist && win->cb_interface[events_cb_index] != NULL) {
// Call user all-events cb
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_interface_bind_handler_all() -> User all-events callback @ 0x%p\n",
win->cb_interface[events_cb_index]
);
- printf("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->event_type [%zu]\n", e->event_type);
- printf("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->element [%s]\n", e->element);
- printf("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->event_number %zu\n", e->event_number);
- printf("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->bind_id %zu\n", e->bind_id);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->event_type [%zu]\n", e->event_type);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->element [%s]\n", e->element);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->event_number %zu\n", e->event_number);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler_all() -> User all-events e->bind_id %zu\n", e->bind_id);
#endif
// Call all-events cb
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interface_bind_handler_all() -> Calling user all-events callback at address 0x%p\n[Call]\n", win->cb_interface[events_cb_index]);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler_all() -> Calling user all-events callback at address 0x%p\n[Call]\n", win->cb_interface[events_cb_index]);
#endif
win->cb_interface[events_cb_index](e->window, e->event_type, e->element, e->event_number, e->bind_id);
}
@@ -3810,7 +3867,7 @@ static void _webui_interface_bind_handler_all(webui_event_t* e) {
static void _webui_interface_bind_handler(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interface_bind_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler()\n");
#endif
// Initialization
@@ -3827,18 +3884,18 @@ static void _webui_interface_bind_handler(webui_event_t* e) {
bool exist = _webui_get_cb_index(win, e->element, &cb_index);
if (exist && win->cb_interface[cb_index] != NULL) {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_interface_bind_handler() -> User callback @ 0x%p\n",
win->cb_interface[cb_index]
);
- printf("[Core]\t\t_webui_interface_bind_handler() -> e->event_type [%zu]\n", e->event_type);
- printf("[Core]\t\t_webui_interface_bind_handler() -> e->element [%s]\n", e->element);
- printf("[Core]\t\t_webui_interface_bind_handler() -> e->event_number %zu\n", e->event_number);
- printf("[Core]\t\t_webui_interface_bind_handler() -> e->bind_id %zu\n", e->bind_id);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler() -> e->event_type [%zu]\n", e->event_type);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler() -> e->element [%s]\n", e->element);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler() -> e->event_number %zu\n", e->event_number);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler() -> e->bind_id %zu\n", e->bind_id);
#endif
// Call cb
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interface_bind_handler() -> Calling user callback at address 0x%p\n[Call]\n", win->cb_interface[cb_index]);
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler() -> Calling user callback at address 0x%p\n[Call]\n", win->cb_interface[cb_index]);
#endif
win->cb_interface[cb_index](e->window, e->event_type, e->element, e->event_number, e->bind_id);
}
@@ -3851,7 +3908,7 @@ static void _webui_interface_bind_handler(webui_event_t* e) {
// Async response wait
if (_webui.config.asynchronous_response) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interface_bind_handler() -> Waiting for asynchronous response...\n");
+ _webui_log_debug("[Core]\t\t_webui_interface_bind_handler() -> Waiting for asynchronous response...\n");
#endif
bool done = false;
while (!done) {
@@ -3864,7 +3921,7 @@ static void _webui_interface_bind_handler(webui_event_t* e) {
#ifdef WEBUI_LOG
// Print cb response
- printf(
+ _webui_log(
"[Core]\t\t_webui_interface_bind_handler() -> user-callback response [%s]\n",
event_inf->response
);
@@ -3875,7 +3932,7 @@ static void _webui_interface_bind_handler(webui_event_t* e) {
const char* webui_interface_get_string_at(size_t window, size_t event_number, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_string_at([%zu], [%zu], [%zu])\n", window, event_number, index);
+ _webui_log_info("[User] webui_interface_get_string_at([%zu], [%zu], [%zu])\n", window, event_number, index);
#endif
// Dereference
@@ -3894,7 +3951,7 @@ const char* webui_interface_get_string_at(size_t window, size_t event_number, si
long long int webui_interface_get_int_at(size_t window, size_t event_number, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_int_at([%zu], [%zu], [%zu])\n", window, event_number, index);
+ _webui_log_info("[User] webui_interface_get_int_at([%zu], [%zu], [%zu])\n", window, event_number, index);
#endif
// Dereference
@@ -3913,7 +3970,7 @@ long long int webui_interface_get_int_at(size_t window, size_t event_number, siz
double webui_interface_get_float_at(size_t window, size_t event_number, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_float_at([%zu], [%zu], [%zu])\n", window, event_number, index);
+ _webui_log_info("[User] webui_interface_get_float_at([%zu], [%zu], [%zu])\n", window, event_number, index);
#endif
// Dereference
@@ -3932,7 +3989,7 @@ double webui_interface_get_float_at(size_t window, size_t event_number, size_t i
bool webui_interface_get_bool_at(size_t window, size_t event_number, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_bool_at([%zu], [%zu], [%zu])\n", window, event_number, index);
+ _webui_log_info("[User] webui_interface_get_bool_at([%zu], [%zu], [%zu])\n", window, event_number, index);
#endif
// Dereference
@@ -3951,7 +4008,7 @@ bool webui_interface_get_bool_at(size_t window, size_t event_number, size_t inde
size_t webui_interface_get_size_at(size_t window, size_t event_number, size_t index) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_size_at([%zu], [%zu], [%zu])\n", window, event_number, index);
+ _webui_log_info("[User] webui_interface_get_size_at([%zu], [%zu], [%zu])\n", window, event_number, index);
#endif
// Dereference
@@ -3970,7 +4027,7 @@ size_t webui_interface_get_size_at(size_t window, size_t event_number, size_t in
size_t webui_interface_bind(size_t window, const char* element, void(*func)(size_t, size_t, char* , size_t, size_t)) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_bind([%zu], [%s], [0x%p])\n", window, element, func);
+ _webui_log_info("[User] webui_interface_bind([%zu], [%s], [0x%p])\n", window, element, func);
#endif
// Dereference
@@ -3992,9 +4049,9 @@ size_t webui_interface_bind(size_t window, const char* element, void(*func)(size
void webui_interface_set_response(size_t window, size_t event_number, const char* response) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_set_response()\n");
- printf("[User] webui_interface_set_response() -> event_number %zu \n", event_number);
- printf("[User] webui_interface_set_response() -> Response [%s] \n", response);
+ _webui_log_info("[User] webui_interface_set_response()\n");
+ _webui_log_info("[User] webui_interface_set_response() -> event_number %zu \n", event_number);
+ _webui_log_info("[User] webui_interface_set_response() -> Response [%s] \n", response);
#endif
// Initialization
@@ -4027,16 +4084,16 @@ void webui_interface_set_response(size_t window, size_t event_number, const char
}
#ifdef WEBUI_LOG
- printf("[User] webui_interface_set_response() -> Internal buffer [%s] \n", event_inf->response);
+ _webui_log_info("[User] webui_interface_set_response() -> Internal buffer [%s] \n", event_inf->response);
#endif
}
void webui_interface_set_response_file_handler(size_t window, const void* response, int length) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_set_response_file_handler()\n");
- printf("[User] webui_interface_set_response_file_handler() -> window #%zu\n", window);
- printf("[User] webui_interface_set_response_file_handler() -> Response %d bytes\n", length);
+ _webui_log_info("[User] webui_interface_set_response_file_handler()\n");
+ _webui_log_info("[User] webui_interface_set_response_file_handler() -> window #%zu\n", window);
+ _webui_log_info("[User] webui_interface_set_response_file_handler() -> Response %d bytes\n", length);
#endif
// Initialization
@@ -4062,7 +4119,7 @@ void webui_interface_set_response_file_handler(size_t window, const void* respon
bool webui_interface_is_app_running(void) {
#ifdef WEBUI_LOG
- // printf("[User] webui_interface_is_app_running()\n");
+ // _webui_log_info("[User] webui_interface_is_app_running()\n");
#endif
// Stop if already flagged
@@ -4083,7 +4140,7 @@ bool webui_interface_is_app_running(void) {
#ifdef WEBUI_LOG
if (!app_is_running)
- printf("[User] webui_interface_is_app_running() -> App Stopped\n");
+ _webui_log_info("[User] webui_interface_is_app_running() -> App Stopped\n");
#endif
return app_is_running;
@@ -4092,7 +4149,7 @@ bool webui_interface_is_app_running(void) {
size_t webui_interface_get_window_id(size_t window) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_window_id()\n");
+ _webui_log_info("[User] webui_interface_get_window_id()\n");
#endif
// Initialization
@@ -4109,7 +4166,7 @@ size_t webui_interface_get_window_id(size_t window) {
bool webui_interface_show_client(size_t window, size_t event_number, const char* content) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_show_client()\n");
+ _webui_log_info("[User] webui_interface_show_client()\n");
#endif
// Initialization
@@ -4136,7 +4193,7 @@ bool webui_interface_show_client(size_t window, size_t event_number, const char*
void webui_interface_close_client(size_t window, size_t event_number) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_close_client()\n");
+ _webui_log_info("[User] webui_interface_close_client()\n");
#endif
// Initialization
@@ -4163,7 +4220,7 @@ void webui_interface_close_client(size_t window, size_t event_number) {
void webui_interface_send_raw_client(size_t window, size_t event_number, const char* function, const void* raw, size_t size) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_send_raw_client()\n");
+ _webui_log_info("[User] webui_interface_send_raw_client()\n");
#endif
// Initialization
@@ -4190,7 +4247,7 @@ void webui_interface_send_raw_client(size_t window, size_t event_number, const c
void webui_interface_navigate_client(size_t window, size_t event_number, const char* url) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_navigate_client()\n");
+ _webui_log_info("[User] webui_interface_navigate_client()\n");
#endif
// Initialization
@@ -4217,7 +4274,7 @@ void webui_interface_navigate_client(size_t window, size_t event_number, const c
void webui_interface_run_client(size_t window, size_t event_number, const char* script) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_run_client()\n");
+ _webui_log_info("[User] webui_interface_run_client()\n");
#endif
// Initialization
@@ -4244,7 +4301,7 @@ void webui_interface_run_client(size_t window, size_t event_number, const char*
bool webui_interface_script_client(size_t window, size_t event_number, const char* script, size_t timeout, char* buffer, size_t buffer_length) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_script_client()\n");
+ _webui_log_info("[User] webui_interface_script_client()\n");
#endif
// Initialization
@@ -4271,7 +4328,7 @@ bool webui_interface_script_client(size_t window, size_t event_number, const cha
void* webui_interface_get_context(size_t window, size_t event_number) {
#ifdef WEBUI_LOG
- printf("[User] webui_interface_get_context([%zu], [%zu])\n", window, event_number);
+ _webui_log_info("[User] webui_interface_get_context([%zu], [%zu])\n", window, event_number);
#endif
// Dereference
@@ -4291,7 +4348,7 @@ void* webui_interface_get_context(size_t window, size_t event_number) {
static bool _webui_ptr_exist(void * ptr) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_ptr_exist()\n");
+ _webui_log_debug("[Core]\t\t_webui_ptr_exist()\n");
#endif
if (ptr == NULL)
@@ -4308,7 +4365,7 @@ static bool _webui_ptr_exist(void * ptr) {
static void _webui_ptr_add(void * ptr, size_t size) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_ptr_add(0x%p)\n", ptr);
+ _webui_log_debug("[Core]\t\t_webui_ptr_add(0x%p)\n", ptr);
#endif
if (ptr == NULL)
@@ -4329,7 +4386,7 @@ static void _webui_ptr_add(void * ptr, size_t size) {
if (_webui.ptr_last_pos >= (WEBUI_MAX_IDS * 2)) {
_webui.ptr_last_pos = ((WEBUI_MAX_IDS * 2) - 1);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ptr_add(0x%p) -> ERROR: Maximum pointer capacity reached.\n",
+ _webui_log_debug("[Core]\t\t_webui_ptr_add(0x%p) -> ERROR: Maximum pointer capacity reached.\n",
ptr);
#endif
}
@@ -4338,7 +4395,7 @@ static void _webui_ptr_add(void * ptr, size_t size) {
_webui.ptr_list[i] = ptr;
_webui.ptr_size[i] = size;
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_ptr_add(0x%p) -> Pointer #%zu saved (%zu + 1 bytes)\n", ptr, i, size);
+ _webui_log_debug("[Core]\t\t_webui_ptr_add(0x%p) -> Pointer #%zu saved (%zu + 1 bytes)\n", ptr, i, size);
#endif
}
}
@@ -4346,7 +4403,7 @@ static void _webui_ptr_add(void * ptr, size_t size) {
static void _webui_free_mem(void * ptr) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_free_mem(0x%p)\n", ptr);
+ _webui_log_debug("[Core]\t\t_webui_free_mem(0x%p)\n", ptr);
#endif
if (ptr == NULL)
@@ -4358,7 +4415,7 @@ static void _webui_free_mem(void * ptr) {
for (size_t i = 0; i < _webui.ptr_last_pos; i++) {
if (_webui.ptr_list[i] == ptr) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_free_mem(0x%p) -> Pointer #%zu freed (%zu + 1 bytes)\n",
+ _webui_log_debug("[Core]\t\t_webui_free_mem(0x%p) -> Pointer #%zu freed (%zu + 1 bytes)\n",
ptr, i, _webui.ptr_size[i]);
#endif
free(ptr);
@@ -4381,7 +4438,7 @@ static void _webui_free_mem(void * ptr) {
static void _webui_free_all_mem(void) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_free_all_mem()\n");
+ _webui_log_debug("[Core]\t\t_webui_free_all_mem()\n");
#endif
_webui_mutex_lock(&_webui.mutex_mem);
@@ -4398,7 +4455,7 @@ static void _webui_free_all_mem(void) {
ptr = _webui.ptr_list[i];
if (ptr != NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_free_all_mem() -> Pointer #%zu freed (%zu + 1 bytes) 0x%p\n",
+ _webui_log_debug("[Core]\t\t_webui_free_all_mem() -> Pointer #%zu freed (%zu + 1 bytes) 0x%p\n",
i, _webui.ptr_size[i], ptr);
#endif
free(ptr);
@@ -4413,17 +4470,17 @@ static void _webui_free_all_mem(void) {
static void _webui_panic(char* msg) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_panic() -> %s.\n", msg);
+ _webui_log_debug("[Core]\t\t_webui_panic() -> %s.\n", msg);
#endif
- fprintf(stderr, "WebUI Error: %s.\n", msg);
+ webui_log_fatal("WebUI Error: %s.\n", msg);
webui_exit();
}
static void * _webui_malloc(size_t size) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_malloc([%zu])\n", size);
+ _webui_log_debug("[Core]\t\t_webui_malloc([%zu])\n", size);
#endif
_webui_mutex_lock(&_webui.mutex_mem);
@@ -4452,7 +4509,7 @@ static void * _webui_malloc(size_t size) {
static _webui_window_t* _webui_dereference_win_ptr(void * ptr) {
#ifdef WEBUI_LOG_VERBOSE
- //printf("[Core]\t\t_webui_dereference_win_ptr()\n");
+ //_webui_log_debug("[Core]\t\t_webui_dereference_win_ptr()\n");
#endif
if (_webui_mutex_app_is_exit_now(WEBUI_MUTEX_GET_STATUS))
@@ -4473,7 +4530,7 @@ static _webui_window_t* _webui_dereference_win_ptr(void * ptr) {
static void _webui_sleep(long unsigned int ms) {
#ifdef WEBUI_LOG_VERBOSE
- // printf("[Core]\t\t_webui_sleep([%zu])\n", ms);
+ // _webui_log_debug("[Core]\t\t_webui_sleep([%zu])\n", ms);
#endif
#ifdef _WIN32
@@ -4489,7 +4546,7 @@ static void _webui_sleep(long unsigned int ms) {
static long _webui_timer_diff(struct timespec * start, struct timespec* end) {
#ifdef WEBUI_LOG_VERBOSE
- // printf("[Core]\t\t_webui_timer_diff()\n");
+ // _webui_log_debug("[Core]\t\t_webui_timer_diff()\n");
#endif
return ((long)(end->tv_sec * 1000) + (long)(end->tv_nsec / 1000000)) -
@@ -4499,7 +4556,7 @@ static long _webui_timer_diff(struct timespec * start, struct timespec* end) {
static void _webui_timer_clock_gettime(struct timespec * spec) {
#ifdef WEBUI_LOG_VERBOSE
- // printf("[Core]\t\t_webui_timer_clock_gettime()\n");
+ // _webui_log_debug("[Core]\t\t_webui_timer_clock_gettime()\n");
#endif
#ifdef _WIN32
@@ -4516,7 +4573,7 @@ static void _webui_timer_clock_gettime(struct timespec * spec) {
static void _webui_timer_start(_webui_timer_t* t) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_timer_start()\n");
+ _webui_log_debug("[Core]\t\t_webui_timer_start()\n");
#endif
_webui_timer_clock_gettime(&t->start);
@@ -4525,7 +4582,7 @@ static void _webui_timer_start(_webui_timer_t* t) {
static bool _webui_timer_is_end(_webui_timer_t* t, size_t ms) {
#ifdef WEBUI_LOG_VERBOSE
- // printf("[Core]\t\t_webui_timer_is_end()\n");
+ // _webui_log_debug("[Core]\t\t_webui_timer_is_end()\n");
#endif
_webui_timer_clock_gettime(&t->now);
@@ -4539,7 +4596,7 @@ static bool _webui_timer_is_end(_webui_timer_t* t, size_t ms) {
static bool _webui_is_empty(const char* s) {
#ifdef WEBUI_LOG_VERBOSE
- //printf("[Core]\t\t_webui_is_empty()\n");
+ //_webui_log_debug("[Core]\t\t_webui_is_empty()\n");
#endif
if ((s != NULL) && (s[0] != '\0'))
@@ -4550,7 +4607,7 @@ static bool _webui_is_empty(const char* s) {
static size_t _webui_strlen(const char* s) {
#ifdef WEBUI_LOG_VERBOSE
- //printf("[Core]\t\t_webui_strlen()\n");
+ //_webui_log_debug("[Core]\t\t_webui_strlen()\n");
#endif
if (_webui_is_empty(s))
@@ -4568,7 +4625,7 @@ static size_t _webui_strlen(const char* s) {
static bool _webui_file_exist_mg(_webui_window_t* win, struct mg_connection* client) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_file_exist_mg()\n");
+ _webui_log_debug("[Core]\t\t_webui_file_exist_mg()\n");
#endif
char* file;
@@ -4601,7 +4658,7 @@ static bool _webui_file_exist_mg(_webui_window_t* win, struct mg_connection* cli
static bool _webui_is_valid_url(const char* url) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_is_valid_url([%.8s...])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_is_valid_url([%.8s...])\n", url);
#endif
if ((_webui_is_empty(url)) || (url[0] != 'h'))
@@ -4614,7 +4671,7 @@ static bool _webui_is_valid_url(const char* url) {
static bool _webui_open_url_native(const char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_open_url_native([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_open_url_native([%s])\n", url);
#endif
#if defined(_WIN32)
@@ -4635,7 +4692,7 @@ static bool _webui_open_url_native(const char* url) {
static bool _webui_file_exist(const char* path) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_file_exist([%s])\n", path);
+ _webui_log_debug("[Core]\t\t_webui_file_exist([%s])\n", path);
#endif
if (_webui_is_empty(path))
@@ -4664,7 +4721,7 @@ static bool _webui_file_exist(const char* path) {
#endif
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_file_exist() -> Parsed to [%s]\n", full_path);
+ _webui_log_debug("[Core]\t\t_webui_file_exist() -> Parsed to [%s]\n", full_path);
#endif
#if defined(_WIN32)
@@ -4684,7 +4741,7 @@ static bool _webui_file_exist(const char* path) {
static const char* _webui_get_extension(const char* f) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_extension()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_extension()\n");
#endif
if (f == NULL)
@@ -4700,7 +4757,7 @@ static const char* _webui_get_extension(const char* f) {
static uint16_t _webui_get_run_id(void) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_run_id()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_run_id()\n");
#endif
if (_webui.run_last_id >= WEBUI_MAX_IDS)
@@ -4711,7 +4768,7 @@ static uint16_t _webui_get_run_id(void) {
static bool _webui_socket_test_listen_mg(size_t port_num) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_socket_test_listen_mg([%zu])\n", port_num);
+ _webui_log_debug("[Core]\t\t_webui_socket_test_listen_mg([%zu])\n", port_num);
#endif
// HTTP Port Test
@@ -4746,7 +4803,7 @@ static bool _webui_socket_test_listen_mg(size_t port_num) {
static bool _webui_port_is_used(size_t port_num) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_port_is_used([%zu])\n", port_num);
+ _webui_log_debug("[Core]\t\t_webui_port_is_used([%zu])\n", port_num);
#endif
#ifdef _WIN32
@@ -4765,7 +4822,7 @@ static bool _webui_port_is_used(size_t port_num) {
static char* _webui_get_file_name_from_url(const char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_file_name_from_url([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_get_file_name_from_url([%s])\n", url);
#endif
if (_webui_is_empty(url))
@@ -4801,7 +4858,7 @@ static char* _webui_get_file_name_from_url(const char* url) {
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_file_name_from_url() -> File name: [%s]\n", file);
+ _webui_log_debug("[Core]\t\t_webui_get_file_name_from_url() -> File name: [%s]\n", file);
#endif
return file;
@@ -4810,7 +4867,7 @@ static char* _webui_get_file_name_from_url(const char* url) {
static char* _webui_get_full_path(_webui_window_t* win, const char* file) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_full_path([%s])\n", file);
+ _webui_log_debug("[Core]\t\t_webui_get_full_path([%s])\n", file);
#endif
if (!file)
@@ -4835,7 +4892,7 @@ static char* _webui_get_full_path(_webui_window_t* win, const char* file) {
#endif
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_get_full_path() -> Full path: [%s]\n", full_path);
+ _webui_log_debug("[Core]\t\t_webui_get_full_path() -> Full path: [%s]\n", full_path);
#endif
return full_path;
@@ -4878,7 +4935,7 @@ static void _webui_free_event_inf(_webui_window_t* win, size_t event_num) {
static int _webui_external_file_handler(_webui_window_t* win, struct mg_connection* client, size_t client_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_external_file_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_external_file_handler()\n");
#endif
int http_status_code = 0;
@@ -4909,9 +4966,9 @@ static int _webui_external_file_handler(_webui_window_t* win, struct mg_connecti
if(win->files_handler_window) {
pt = win->files_handler_window;
}
- printf("[Core]\t\t_webui_external_file_handler() -> Path [%s]\n", url);
- printf("[Core]\t\t_webui_external_file_handler() -> Calling custom files handler callback at address 0x%p\n", pt);
- printf("[Call]\n");
+ _webui_log_debug("[Core]\t\t_webui_external_file_handler() -> Path [%s]\n", url);
+ _webui_log_debug("[Core]\t\t_webui_external_file_handler() -> Calling custom files handler callback at address 0x%p\n", pt);
+ _webui_log("[Call]\n");
#endif
// Async response ini
@@ -4934,7 +4991,7 @@ static int _webui_external_file_handler(_webui_window_t* win, struct mg_connecti
// `callback_resp` is NULL now, we need to
// wait for the response that will come later.
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_external_file_handler() -> Waiting for asynchronous response...\n");
+ _webui_log_debug("[Core]\t\t_webui_external_file_handler() -> Waiting for asynchronous response...\n");
#endif
bool done = false;
while (!done) {
@@ -4956,15 +5013,15 @@ static int _webui_external_file_handler(_webui_window_t* win, struct mg_connecti
length = _webui_strlen(callback_resp);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_external_file_handler() -> Custom files handler found (%zu bytes)\n",
+ _webui_log_debug("[Core]\t\t_webui_external_file_handler() -> Custom files handler found (%zu bytes)\n",
length
);
#endif
#ifdef WEBUI_LOG
- printf("---[ External File Handler ]--------\n");
+ _webui_log("---[ External File Handler ]--------\n");
_webui_print_ascii((const char*)callback_resp, length);
- printf("\n------------------------------------\n");
+ _webui_log("\n------------------------------------\n");
#endif
// Send user data (Header + Body)
@@ -4978,7 +5035,7 @@ static int _webui_external_file_handler(_webui_window_t* win, struct mg_connecti
}
else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_external_file_handler() -> Custom files handler failed\n");
+ _webui_log_debug("[Core]\t\t_webui_external_file_handler() -> Custom files handler failed\n");
#endif
}
@@ -4993,7 +5050,7 @@ static int _webui_external_file_handler(_webui_window_t* win, struct mg_connecti
static int _webui_serve_file(_webui_window_t* win, struct mg_connection* client, size_t client_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_serve_file()\n");
+ _webui_log_debug("[Core]\t\t_webui_serve_file()\n");
#endif
// Serve a normal text based file
@@ -5003,7 +5060,7 @@ static int _webui_serve_file(_webui_window_t* win, struct mg_connection* client,
const char* url = ri->local_uri;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_serve_file() -> Looking for file locally\n");
+ _webui_log_debug("[Core]\t\t_webui_serve_file() -> Looking for file locally\n");
#endif
// Get full path
@@ -5032,7 +5089,7 @@ static int _webui_serve_file(_webui_window_t* win, struct mg_connection* client,
static bool _webui_bun_exist(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_bun_exist()\n");
+ _webui_log_debug("[Core]\t\t_webui_bun_exist()\n");
#endif
static bool found = false;
@@ -5051,7 +5108,7 @@ static bool _webui_bun_exist(_webui_window_t* win) {
static bool _webui_deno_exist(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_deno_exist()\n");
+ _webui_log_debug("[Core]\t\t_webui_deno_exist()\n");
#endif
static bool found = false;
@@ -5070,7 +5127,7 @@ static bool _webui_deno_exist(_webui_window_t* win) {
static bool _webui_nodejs_exist(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_nodejs_exist()\n");
+ _webui_log_debug("[Core]\t\t_webui_nodejs_exist()\n");
#endif
static bool found = false;
@@ -5089,7 +5146,7 @@ static bool _webui_nodejs_exist(_webui_window_t* win) {
static const char* _webui_interpret_command(const char* cmd) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interpret_command([%s])\n", cmd);
+ _webui_log_debug("[Core]\t\t_webui_interpret_command([%s])\n", cmd);
#endif
// Run the command with redirection of errors to stdout
@@ -5203,7 +5260,7 @@ static void _webui_mutex_destroy(webui_mutex_t* mutex) {
static int _webui_interpret_file(_webui_window_t* win, struct mg_connection* client, char* index, size_t client_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_interpret_file()\n");
+ _webui_log_debug("[Core]\t\t_webui_interpret_file()\n");
#endif
// Interpret the file using JavaScript/TypeScript runtimes
@@ -5395,7 +5452,7 @@ static int _webui_interpret_file(_webui_window_t* win, struct mg_connection* cli
static const char* _webui_generate_js_bridge(_webui_window_t* win, struct mg_connection* client) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_generate_js_bridge()\n");
+ _webui_log_debug("[Core]\t\t_webui_generate_js_bridge()\n");
#endif
_webui_mutex_lock(&_webui.mutex_bridge);
@@ -5525,7 +5582,7 @@ static bool _webui_mutex_is_webview_update(_webui_window_t* win, int update) {
static void _webui_webview_update(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_webview_update(%zu)\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_webview_update(%zu)\n", win->num);
#endif
#ifdef _WIN32
@@ -5543,7 +5600,7 @@ static void _webui_webview_update(_webui_window_t* win) {
static bool _webui_browser_create_new_profile(_webui_window_t* win, size_t browser) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_create_new_profile(%zu)\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_browser_create_new_profile(%zu)\n", browser);
#endif
// Default local machine profile
@@ -5571,7 +5628,7 @@ static bool _webui_browser_create_new_profile(_webui_window_t* win, size_t brows
}
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_browser_create_new_profile(%zu) -> Generating WebUI profile\n",
browser
);
@@ -5667,7 +5724,7 @@ static bool _webui_browser_create_new_profile(_webui_window_t* win, size_t brows
temp, os_sep, os_sep, ff) >= WEBUI_MAX_PATH) {
// Generated path is too big
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_browser_create_new_profile(%zu) -> "
"Generated Firefox profile folder path is too big\n",
browser
@@ -5758,7 +5815,7 @@ static bool _webui_browser_create_new_profile(_webui_window_t* win, size_t brows
static bool _webui_folder_exist(const char* folder) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_folder_exist([%s])\n", folder);
+ _webui_log_debug("[Core]\t\t_webui_folder_exist([%s])\n", folder);
#endif
#if defined(_WIN32)
@@ -5779,7 +5836,7 @@ static bool _webui_folder_exist(const char* folder) {
static void _webui_delete_folder(char* folder) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_delete_folder([%s])\n", folder);
+ _webui_log_debug("[Core]\t\t_webui_delete_folder([%s])\n", folder);
#endif
char command[1024];
@@ -5793,7 +5850,7 @@ static void _webui_delete_folder(char* folder) {
for (size_t i = 0; i < 6; i++) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_delete_folder() -> Running [%s] \n", command);
+ _webui_log_debug("[Core]\t\t_webui_delete_folder() -> Running [%s] \n", command);
#endif
#if defined(_WIN32)
@@ -5811,7 +5868,7 @@ static void _webui_delete_folder(char* folder) {
static uint32_t _webui_get_token(const char* data) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_token()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_token()\n");
#endif
uint32_t token = 0;
@@ -5823,7 +5880,7 @@ static uint32_t _webui_get_token(const char* data) {
token |= ((uint32_t) data[WEBUI_PROTOCOL_TOKEN + 3]&0xFF) << 24;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_token() -> 0x%08X\n", token);
+ _webui_log_debug("[Core]\t\t_webui_get_token() -> 0x%08X\n", token);
#endif
return token;
@@ -5832,7 +5889,7 @@ static uint32_t _webui_get_token(const char* data) {
static uint16_t _webui_get_id(const char* data) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_id()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_id()\n");
#endif
uint16_t id = 0;
@@ -5842,7 +5899,7 @@ static uint16_t _webui_get_id(const char* data) {
id |= ((uint16_t) data[WEBUI_PROTOCOL_ID + 1]&0xFF) << 8;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_id() -> 0x%04X\n", id);
+ _webui_log_debug("[Core]\t\t_webui_get_id() -> 0x%04X\n", id);
#endif
return id;
@@ -5851,7 +5908,7 @@ static uint16_t _webui_get_id(const char* data) {
static void _webui_send_all(_webui_window_t* win, uint16_t id, unsigned char cmd, const char* data, size_t len) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_send_all()\n");
+ _webui_log_debug("[Core]\t\t_webui_send_all()\n");
#endif
// Send the WebSocket packet to a all connected clients if
@@ -5880,7 +5937,7 @@ static void _webui_send_client(
uint16_t id, unsigned char cmd, const char* data, size_t len, bool token_bypass) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_send_client()\n");
+ _webui_log_debug("[Core]\t\t_webui_send_client()\n");
#endif
// Get connection id
@@ -5897,10 +5954,10 @@ static void _webui_send_client(
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_send_client() -> Connection ID = %zu \n", connection_id);
- printf("[Core]\t\t_webui_send_client() -> Packet ID = 0x%04X \n", id);
- printf("[Core]\t\t_webui_send_client() -> Packet CMD = 0x%02x \n", cmd);
- printf("[Core]\t\t_webui_send_client() -> Packet Data = %zu bytes \n", len);
+ _webui_log_debug("[Core]\t\t_webui_send_client() -> Connection ID = %zu \n", connection_id);
+ _webui_log_debug("[Core]\t\t_webui_send_client() -> Packet ID = 0x%04X \n", id);
+ _webui_log_debug("[Core]\t\t_webui_send_client() -> Packet CMD = 0x%02x \n", cmd);
+ _webui_log_debug("[Core]\t\t_webui_send_client() -> Packet Data = %zu bytes \n", len);
#endif
// Protocol
@@ -5956,7 +6013,7 @@ static char* _webui_str_dup(const char* src) {
static const char* _webui_get_temp_path() {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_temp_path()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_temp_path()\n");
#endif
#ifdef _WIN32
@@ -5990,7 +6047,7 @@ static const char* _webui_get_temp_path() {
static bool _webui_is_google_chrome_folder(const char* folder) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_is_google_chrome_folder([%s])\n", folder);
+ _webui_log_debug("[Core]\t\t_webui_is_google_chrome_folder([%s])\n", folder);
#endif
char browser_full_path[WEBUI_MAX_PATH];
@@ -6018,7 +6075,7 @@ static bool _webui_is_google_chrome_folder(const char* folder) {
static bool _webui_custom_browser_exist(_webui_window_t* win, size_t browser) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_custom_browser_exist([%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_custom_browser_exist([%zu])\n", browser);
#endif
if (!_webui.custom_browser_folder_path)
@@ -6138,7 +6195,7 @@ static bool _webui_custom_browser_exist(_webui_window_t* win, size_t browser) {
static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_exist([%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_browser_exist([%zu])\n", browser);
#endif
// Check if a web browser is installed on this machine
@@ -6851,7 +6908,7 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
static void _webui_clean(void) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_clean()\n");
+ _webui_log_debug("[Core]\t\t_webui_clean()\n");
#endif
static bool cleaned = false;
@@ -6884,14 +6941,14 @@ static void _webui_clean(void) {
_webui_condition_destroy(&_webui.condition_wait);
#ifdef WEBUI_LOG
- printf("[Core]\t\tWebUI exit successfully\n");
+ _webui_log_debug("[Core]\t\tWebUI exit successfully\n");
#endif
}
static int _webui_cmd_sync(_webui_window_t* win, char* cmd, bool show) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_cmd_sync()\n");
+ _webui_log_debug("[Core]\t\t_webui_cmd_sync()\n");
#endif
// Run sync command and
@@ -6904,14 +6961,14 @@ static int _webui_cmd_sync(_webui_window_t* win, char* cmd, bool show) {
// Using: _CMD_
WEBUI_SN_PRINTF_STATIC(buf, sizeof(buf), "cmd /c \"%s\" > nul 2>&1", cmd);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_cmd_sync() -> Running [%s] \n", buf);
+ _webui_log_debug("[Core]\t\t_webui_cmd_sync() -> Running [%s] \n", buf);
#endif
return _webui_system_win32(win, buf, show);
#else
// Using: _CMD_
WEBUI_SN_PRINTF_STATIC(buf, sizeof(buf), "%s >>/dev/null 2>>/dev/null", cmd);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_cmd_sync() -> Running [%s] \n", buf);
+ _webui_log_debug("[Core]\t\t_webui_cmd_sync() -> Running [%s] \n", buf);
#endif
int r = system(buf);
r = (r != -1 && r != 127 && WIFEXITED(r)) ? WEXITSTATUS(r) : -1;
@@ -6922,7 +6979,7 @@ static int _webui_cmd_sync(_webui_window_t* win, char* cmd, bool show) {
static int _webui_cmd_async(_webui_window_t* win, char* cmd, bool show) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_cmd_async()\n");
+ _webui_log_debug("[Core]\t\t_webui_cmd_async()\n");
#endif
// Run a async command
@@ -6935,14 +6992,14 @@ static int _webui_cmd_async(_webui_window_t* win, char* cmd, bool show) {
// Using: START "" _CMD_
WEBUI_SN_PRINTF_STATIC(buf, sizeof(buf), "cmd /c \"START \"\" %s\" > nul 2>&1", cmd);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_cmd_async() -> Running [%s] \n", buf);
+ _webui_log_debug("[Core]\t\t_webui_cmd_async() -> Running [%s] \n", buf);
#endif
return _webui_system_win32(win, buf, show);
#else
// Using: _CMD_ &
WEBUI_SN_PRINTF_STATIC(buf, sizeof(buf), "%s >>/dev/null 2>>/dev/null &", cmd);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_cmd_async() -> Running [%s] \n", buf);
+ _webui_log_debug("[Core]\t\t_webui_cmd_async() -> Running [%s] \n", buf);
#endif
int r = system(buf);
r = (r != -1 && r != 127 && WIFEXITED(r)) ? WEXITSTATUS(r) : -1;
@@ -6953,7 +7010,7 @@ static int _webui_cmd_async(_webui_window_t* win, char* cmd, bool show) {
static int _webui_run_browser(_webui_window_t* win, char* cmd) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_run_browser()\n");
+ _webui_log_debug("[Core]\t\t_webui_run_browser()\n");
#endif
// Run a async command
@@ -6963,7 +7020,7 @@ static int _webui_run_browser(_webui_window_t* win, char* cmd) {
static int _webui_get_browser_args(_webui_window_t* win, size_t browser, char* buffer, size_t len) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_browser_args([%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_get_browser_args([%zu])\n", browser);
#endif
const char* chromium_options[] = {
@@ -7069,7 +7126,7 @@ static int _webui_get_browser_args(_webui_window_t* win, size_t browser, char* b
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_browser_args() -> Unknown Browser (%zu)\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_get_browser_args() -> Unknown Browser (%zu)\n", browser);
#endif
WEBUI_STR_COPY_STATIC(buffer, len, "");
return 0;
@@ -7078,7 +7135,7 @@ static int _webui_get_browser_args(_webui_window_t* win, size_t browser, char* b
static bool _webui_browser_start_chrome(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_chrome([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_chrome([%s])\n", address);
#endif
// -- Google Chrome ----------------------
@@ -7110,7 +7167,7 @@ static bool _webui_browser_start_chrome(_webui_window_t* win, const char* addres
static bool _webui_browser_start_edge(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_edge([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_edge([%s])\n", address);
#endif
// -- Microsoft Edge ----------------------
@@ -7142,7 +7199,7 @@ static bool _webui_browser_start_edge(_webui_window_t* win, const char* address)
static bool _webui_browser_start_epic(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_epic([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_epic([%s])\n", address);
#endif
// -- Epic Privacy Browser ----------------------
@@ -7174,7 +7231,7 @@ static bool _webui_browser_start_epic(_webui_window_t* win, const char* address)
static bool _webui_browser_start_vivaldi(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_vivaldi([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_vivaldi([%s])\n", address);
#endif
// -- Vivaldi Browser ----------------------
@@ -7206,7 +7263,7 @@ static bool _webui_browser_start_vivaldi(_webui_window_t* win, const char* addre
static bool _webui_browser_start_brave(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_brave([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_brave([%s])\n", address);
#endif
// -- Brave Browser ----------------------
@@ -7238,7 +7295,7 @@ static bool _webui_browser_start_brave(_webui_window_t* win, const char* address
static bool _webui_browser_start_firefox(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_firefox([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_firefox([%s])\n", address);
#endif
// -- Mozilla Firefox ----------------------
@@ -7270,7 +7327,7 @@ static bool _webui_browser_start_firefox(_webui_window_t* win, const char* addre
static bool _webui_browser_start_yandex(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_yandex([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_yandex([%s])\n", address);
#endif
// -- Yandex Browser ----------------------
@@ -7302,7 +7359,7 @@ static bool _webui_browser_start_yandex(_webui_window_t* win, const char* addres
static bool _webui_browser_start_chromium(_webui_window_t* win, const char* address) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start_chromium([%s])\n", address);
+ _webui_log_debug("[Core]\t\t_webui_browser_start_chromium([%s])\n", address);
#endif
// -- The Chromium Projects -------------------
@@ -7334,7 +7391,7 @@ static bool _webui_browser_start_chromium(_webui_window_t* win, const char* addr
static bool _webui_browser_start(_webui_window_t* win, const char* address, size_t _browser) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_browser_start([%s], [%zu])\n", address, _browser);
+ _webui_log_debug("[Core]\t\t_webui_browser_start([%s], [%zu])\n", address, _browser);
#endif
// Non existing browser
@@ -7530,7 +7587,7 @@ static size_t _webui_get_child_process_id(_webui_window_t* win) {
static bool _webui_is_process_running(const char* process_name) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_is_process_running([%s])\n", process_name);
+ _webui_log_debug("[Core]\t\t_webui_is_process_running([%s])\n", process_name);
#endif
bool isRunning = false;
@@ -7622,7 +7679,7 @@ static bool _webui_is_process_running(const char* process_name) {
static size_t _webui_find_the_best_browser(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_find_the_best_browser()\n");
+ _webui_log_debug("[Core]\t\t_webui_find_the_best_browser()\n");
#endif
// #1 - Chrome - Works perfectly
@@ -7699,7 +7756,7 @@ static size_t _webui_find_the_best_browser(_webui_window_t* win) {
static bool _webui_show(_webui_window_t* win, struct mg_connection* client, const char* content, size_t browser) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show([%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_show([%zu])\n", browser);
#endif
if (_webui_is_empty(content))
@@ -7714,7 +7771,7 @@ static bool _webui_show(_webui_window_t* win, struct mg_connection* client, cons
// URL
if (_webui_is_valid_url(content_cpy)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show() -> URL: [%s]\n", content_cpy);
+ _webui_log_debug("[Core]\t\t_webui_show() -> URL: [%s]\n", content_cpy);
#endif
return _webui_show_window(win, client, content_cpy, WEBUI_SHOW_URL, browser);
}
@@ -7724,20 +7781,20 @@ static bool _webui_show(_webui_window_t* win, struct mg_connection* client, cons
strstr(content_cpy, " Embedded HTML:\n");
- printf("- - -[HTML]- - - - - - - - - -\n%s\n- - - - - - - - - - - - - - - -\n", content_cpy);
+ _webui_log_debug("[Core]\t\t_webui_show() -> Embedded HTML:\n");
+ _webui_log("- - -[HTML]- - - - - - - - - -\n%s\n- - - - - - - - - - - - - - - -\n", content_cpy);
#endif
return _webui_show_window(win, client, content_cpy, WEBUI_SHOW_HTML, browser);
}
// Folder
else if (_webui_folder_exist(content_cpy)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show() -> Folder: [%s]\n", content_cpy);
+ _webui_log_debug("[Core]\t\t_webui_show() -> Folder: [%s]\n", content_cpy);
#endif
// Set root folder
if (!webui_set_root_folder(win->num, content_cpy)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show() -> Failed to set folder root path\n");
+ _webui_log_debug("[Core]\t\t_webui_show() -> Failed to set folder root path\n");
#endif
_webui_free_mem((void*)content_cpy);
return false;
@@ -7747,7 +7804,7 @@ static bool _webui_show(_webui_window_t* win, struct mg_connection* client, cons
// File
else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show() -> File: [%s]\n", content_cpy);
+ _webui_log_debug("[Core]\t\t_webui_show() -> File: [%s]\n", content_cpy);
#endif
if (content_len > WEBUI_MAX_PATH || strstr(content_cpy, "<"))
return false;
@@ -7760,7 +7817,7 @@ static bool _webui_show(_webui_window_t* win, struct mg_connection* client, cons
static int _webui_tls_initialization(void * ssl_ctx, void * ptr) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_tls_initialization()\n");
+ _webui_log_debug("[Core]\t\t_webui_tls_initialization()\n");
#endif
SSL_CTX * ctx = (SSL_CTX * ) ssl_ctx;
@@ -7776,14 +7833,14 @@ static int _webui_tls_initialization(void * ssl_ctx, void * ptr) {
X509 * cert = PEM_read_bio_X509(bio_cert, NULL, 0, NULL);
if (cert == NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_tls_initialization() -> PEM_read_bio_X509 failed\n");
+ _webui_log_debug("[Core]\t\t_webui_tls_initialization() -> PEM_read_bio_X509 failed\n");
#endif
WEBUI_ASSERT("PEM_read_bio_X509 failed");
return -1;
}
if (SSL_CTX_use_certificate(ctx, cert) <= 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_tls_initialization() -> SSL_CTX_use_certificate failed\n");
+ _webui_log_debug("[Core]\t\t_webui_tls_initialization() -> SSL_CTX_use_certificate failed\n");
#endif
WEBUI_ASSERT("SSL_CTX_use_certificate failed");
return -1;
@@ -7796,14 +7853,14 @@ static int _webui_tls_initialization(void * ssl_ctx, void * ptr) {
EVP_PKEY * private_key = PEM_read_bio_PrivateKey(bio_key, NULL, 0, NULL);
if (private_key == NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_tls_initialization() -> PEM_read_bio_PrivateKey failed\n");
+ _webui_log_debug("[Core]\t\t_webui_tls_initialization() -> PEM_read_bio_PrivateKey failed\n");
#endif
WEBUI_ASSERT("PEM_read_bio_PrivateKey failed");
return -1;
}
if (SSL_CTX_use_PrivateKey(ctx, private_key) <= 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_tls_initialization() -> SSL_CTX_use_PrivateKey failed\n");
+ _webui_log_debug("[Core]\t\t_webui_tls_initialization() -> SSL_CTX_use_PrivateKey failed\n");
#endif
WEBUI_ASSERT("SSL_CTX_use_PrivateKey failed");
return -1;
@@ -7817,7 +7874,7 @@ static int _webui_tls_initialization(void * ssl_ctx, void * ptr) {
static bool _webui_tls_generate_self_signed_cert(char* root_cert, char* root_key, char* ssl_cert, char* ssl_key) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_tls_generate_self_signed_cert()\n");
+ _webui_log_debug("[Core]\t\t_webui_tls_generate_self_signed_cert()\n");
#endif
int ret = 0;
@@ -8077,13 +8134,13 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
#ifdef WEBUI_LOG
if (type == WEBUI_SHOW_HTML)
- printf("[Core]\t\t_webui_show_window(HTML, [%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_show_window(HTML, [%zu])\n", browser);
else if (type == WEBUI_SHOW_URL)
- printf("[Core]\t\t_webui_show_window(URL, [%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_show_window(URL, [%zu])\n", browser);
else if (type == WEBUI_SHOW_FOLDER)
- printf("[Core]\t\t_webui_show_window(FOLDER, [%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_show_window(FOLDER, [%zu])\n", browser);
else
- printf("[Core]\t\t_webui_show_window(FILE, [%zu])\n", browser);
+ _webui_log_debug("[Core]\t\t_webui_show_window(FILE, [%zu])\n", browser);
#endif
#ifdef WEBUI_TLS
@@ -8091,7 +8148,7 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
if (_webui_is_empty(_webui.ssl_cert) || _webui_is_empty(_webui.ssl_key)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> Generating self-signed TLS "
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> Generating self-signed TLS "
"certificate\n");
#endif
@@ -8105,7 +8162,7 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
unsigned long err = ERR_get_error();
char err_buf[1024];
ERR_error_string_n(err, err_buf, sizeof(err_buf));
- printf(
+ _webui_log(
"[Core]\t\t_webui_show_window() -> Generating self-signed TLS "
"certificate failed:\n%s\n",
err_buf
@@ -8125,12 +8182,12 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
_webui.ssl_key = ssl_key;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> Self-signed SSL/TLS "
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> Self-signed SSL/TLS "
"Certificate:\nRoot:\n");
- printf("%s\n", (const char*)_webui.root_cert);
- printf("%s\nServer:\n", (const char*)_webui.root_key);
- printf("%s\n", (const char*)_webui.ssl_cert);
- printf("%s\n", (const char*)_webui.ssl_key);
+ _webui_log("%s\n", (const char*)_webui.root_cert);
+ _webui_log("%s\nServer:\n", (const char*)_webui.root_key);
+ _webui_log("%s\n", (const char*)_webui.ssl_cert);
+ _webui_log("%s\n", (const char*)_webui.ssl_key);
#endif
}
#endif
@@ -8239,14 +8296,14 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
// Trying to use WebView
if (_webui_wv_show(win, window_url)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> WebView Found\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> WebView Found\n");
#endif
win->current_browser = Webview;
runWebView = true;
}
else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> WebView Not Found\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> WebView Not Found\n");
#endif
}
}
@@ -8258,13 +8315,13 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
if (browser != NoBrowser) {
if (!_webui_browser_start(win, window_url, browser)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> App-mode browser failed\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> App-mode browser failed\n");
#endif
// Opening App-mode browser failed
// let's try opening UI in native default browser
if (browser == AnyBrowser && _webui_open_url_native(window_url)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> Native browser succeeded\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> Native browser succeeded\n");
#endif
runBrowser = true;
// To avoid terminating the user's native browser on exit
@@ -8272,19 +8329,19 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
}
else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> Native browser failed\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> Native browser failed\n");
#endif
}
}
else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> App-mode browser succeeded\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> App-mode browser succeeded\n");
#endif
runBrowser = true;
}
} else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> Starting server only mode (NoBrowser)\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> Starting server only mode (NoBrowser)\n");
#endif
runBrowser = true;
}
@@ -8357,7 +8414,7 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
if ((browser != NoBrowser) && _webui.config.show_wait_connection) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_show_window() -> Waiting for window connection & token validation\n");
+ _webui_log_debug("[Core]\t\t_webui_show_window() -> Waiting for window connection & token validation\n");
#endif
size_t timeout = (_webui.startup_timeout > 0 ?
@@ -8434,7 +8491,7 @@ static void _webui_window_event(
size_t event_number, size_t client_id, const char* cookies) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_window_event([%zu], [%zu], [%s])\n",
+ _webui_log_debug("[Core]\t\t_webui_window_event([%zu], [%zu], [%s])\n",
win->num, connection_id, element);
#endif
@@ -8455,8 +8512,8 @@ static void _webui_window_event(
if (exist && win->cb[events_cb_index] != NULL) {
// Call user all-events cb
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_window_event() -> Calling all-events user callback at address 0x%p\n", win->cb[events_cb_index]);
- printf("[Call]\n");
+ _webui_log_debug("[Core]\t\t_webui_window_event() -> Calling all-events user callback at address 0x%p\n", win->cb[events_cb_index]);
+ _webui_log("[Call]\n");
#endif
e.bind_id = events_cb_index;
win->cb[events_cb_index](&e);
@@ -8471,8 +8528,8 @@ static void _webui_window_event(
if (exist && win->cb[cb_index] != NULL) {
// Call user cb
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_window_event() -> Calling user callback at address 0x%p\n", win->cb[cb_index]);
- printf("[Call]\n");
+ _webui_log_debug("[Core]\t\t_webui_window_event() -> Calling user callback at address 0x%p\n", win->cb[cb_index]);
+ _webui_log("[Call]\n");
#endif
e.bind_id = cb_index;
win->cb[cb_index](&e);
@@ -8487,7 +8544,7 @@ static void _webui_window_event(
// Async response wait
if (_webui.config.asynchronous_response) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_window_event() -> Waiting for asynchronous response...\n");
+ _webui_log_debug("[Core]\t\t_webui_window_event() -> Waiting for asynchronous response...\n");
#endif
bool done = false;
while (!done) {
@@ -8500,7 +8557,7 @@ static void _webui_window_event(
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_window_event() -> Finished\n");
+ _webui_log_debug("[Core]\t\t_webui_window_event() -> Finished\n");
#endif
}
@@ -8508,12 +8565,12 @@ static void _webui_send_client_ws(_webui_window_t* win, struct mg_connection* cl
size_t connection_id, char* packet, size_t packets_size) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_send_client_ws()\n");
- printf("[Core]\t\t_webui_send_client_ws() -> Client #%zu\n", connection_id);
- printf("[Core]\t\t_webui_send_client_ws() -> Packet size: %zu bytes \n", packets_size);
- printf("[Core]\t\t_webui_send_client_ws() -> Packet hex : [ ");
+ _webui_log_debug("[Core]\t\t_webui_send_client_ws()\n");
+ _webui_log_debug("[Core]\t\t_webui_send_client_ws() -> Client #%zu\n", connection_id);
+ _webui_log_debug("[Core]\t\t_webui_send_client_ws() -> Packet size: %zu bytes \n", packets_size);
+ _webui_log_debug("[Core]\t\t_webui_send_client_ws() -> Packet hex : [ ");
_webui_print_hex(packet, packets_size);
- printf("]\n");
+ _webui_log("]\n");
#endif
if (win == NULL || client == NULL) {
@@ -8535,14 +8592,14 @@ static void _webui_send_client_ws(_webui_window_t* win, struct mg_connection* cl
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_send_client_ws() -> %d bytes sent.\n", ret);
+ _webui_log_debug("[Core]\t\t_webui_send_client_ws() -> %d bytes sent.\n", ret);
#endif
}
static char* _webui_get_current_path(void) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_current_path()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_current_path()\n");
#endif
char* path = (char*)_webui_malloc(WEBUI_MAX_PATH);
@@ -8555,7 +8612,7 @@ static char* _webui_get_current_path(void) {
static void _webui_free_port(size_t port) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_free_port([%zu])\n", port);
+ _webui_log_debug("[Core]\t\t_webui_free_port([%zu])\n", port);
#endif
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
@@ -8569,7 +8626,7 @@ static void _webui_free_port(size_t port) {
static size_t _webui_get_free_port(void) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_free_port()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_free_port()\n");
#endif
size_t port = (rand() % (WEBUI_MAX_PORT + 1 - WEBUI_MIN_PORT)) + WEBUI_MIN_PORT;
@@ -8617,13 +8674,13 @@ static void _webui_init(void) {
_webui.initialized = true;
#ifdef WEBUI_LOG
- printf("[Core]\t\tWebUI v"
+ _webui_log_debug("[Core]\t\tWebUI v"
WEBUI_VERSION " ("
WEBUI_OS ", "
WEBUI_COMPILER ", "
WEBUI_LIB_TYPE ", "
WEBUI_SECURE ")\n");
- printf("[Core]\t\t_webui_init()\n");
+ _webui_log_debug("[Core]\t\t_webui_init()\n");
#endif
// Initializing mutex
@@ -8671,7 +8728,7 @@ static void _webui_init(void) {
static const char* _webui_url_encode(const char* str) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_url_encode()\n");
+ _webui_log_debug("[Core]\t\t_webui_url_encode()\n");
#endif
const char* hex = "0123456789ABCDEF";
@@ -8701,8 +8758,8 @@ static bool _webui_get_cb_index(_webui_window_t* win, const char* element, size_
_webui_mutex_lock(&_webui.mutex_bridge);
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_get_cb_index([%zu])\n", win->num);
- printf("[Core]\t\t_webui_get_cb_index() -> Element: [%s]\n", element);
+ _webui_log_debug("[Core]\t\t_webui_get_cb_index([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_get_cb_index() -> Element: [%s]\n", element);
#endif
// Search
@@ -8711,7 +8768,7 @@ static bool _webui_get_cb_index(_webui_window_t* win, const char* element, size_
if (win->html_elements[i] != NULL) {
if (strcmp(win->html_elements[i], element) == 0) {
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_get_cb_index() -> Found at %zu\n", i);
+ _webui_log_debug("[Core]\t\t_webui_get_cb_index() -> Found at %zu\n", i);
#endif
_webui_mutex_unlock(&_webui.mutex_bridge);
*id = i;
@@ -8722,7 +8779,7 @@ static bool _webui_get_cb_index(_webui_window_t* win, const char* element, size_
}
#ifdef WEBUI_LOG_VERBOSE
- printf("[Core]\t\t_webui_get_cb_index() -> Not found\n");
+ _webui_log_debug("[Core]\t\t_webui_get_cb_index() -> Not found\n");
#endif
_webui_mutex_unlock(&_webui.mutex_bridge);
@@ -8732,16 +8789,16 @@ static bool _webui_get_cb_index(_webui_window_t* win, const char* element, size_
#ifdef WEBUI_LOG
static void _webui_print_hex(const char* data, size_t len) {
for (size_t i = 0; i < len; i++) {
- printf("0x%02X ", (unsigned char)* data);
+ _webui_log_detail("0x%02X ", (unsigned char)* data);
data++;
}
}
static void _webui_print_ascii(const char* data, size_t len) {
for (size_t i = 0; i < len; i++) {
if ((unsigned char)* data == 0x00)
- putchar(0xCF); // ¤
+ _webui_log_detail("%c", 0xCF);
else
- printf("%c", (unsigned char)* data);
+ _webui_log_detail("%c", (unsigned char)* data);
data++;
}
}
@@ -8754,10 +8811,10 @@ static void _webui_http_send_header(
const char* mime_type, size_t body_len, bool cache) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send_header([%zu])\n", win->num);
- printf("[Core]\t\t_webui_http_send_header() -> mime_type: [%s]\n", mime_type);
- printf("[Core]\t\t_webui_http_send_header() -> body_len: [%zu]\n", body_len);
- printf("[Core]\t\t_webui_http_send_header() -> cache: [%d]\n", cache);
+ _webui_log_debug("[Core]\t\t_webui_http_send_header([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_http_send_header() -> mime_type: [%s]\n", mime_type);
+ _webui_log_debug("[Core]\t\t_webui_http_send_header() -> body_len: [%zu]\n", body_len);
+ _webui_log_debug("[Core]\t\t_webui_http_send_header() -> cache: [%d]\n", cache);
#endif
const char* no_cache = "no-cache, no-store, must-revalidate, private, max-age=0";
@@ -8786,7 +8843,7 @@ static void _webui_http_send_header(
set_cookies = true;
_webui.cookies_single_set[win->num] = true;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send() -> New auth cookies [%s]\n",
+ _webui_log_debug("[Core]\t\t_webui_http_send() -> New auth cookies [%s]\n",
_webui.cookies[new_client_id]
);
#endif
@@ -8794,7 +8851,7 @@ static void _webui_http_send_header(
else {
// Cookies list is full
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send() -> Cookies list is full\n");
+ _webui_log_debug("[Core]\t\t_webui_http_send() -> Cookies list is full\n");
#endif
}
}
@@ -8831,9 +8888,9 @@ static void _webui_http_send_header(
}
#ifdef WEBUI_LOG
- printf("---[ HTTP Header ]-----------------\n");
- printf("%s", buffer);
- printf("\n-----------------------------------\n");
+ _webui_log("---[ HTTP Header ]-----------------\n");
+ _webui_log("%s", buffer);
+ _webui_log("\n-----------------------------------\n");
#endif
// Send
@@ -8845,7 +8902,7 @@ static void _webui_http_send_file(
const char* mime_type, const char* path, bool cache) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send_file([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_http_send_file([%zu])\n", win->num);
#endif
// Open the file
@@ -8853,7 +8910,7 @@ static void _webui_http_send_file(
WEBUI_FILE_OPEN(file, path, "rb");
if (!file) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send_file() -> Can't open file [%s]\n", path);
+ _webui_log_debug("[Core]\t\t_webui_http_send_file() -> Can't open file [%s]\n", path);
#endif
_webui_http_send_error(client, webui_html_res_not_available, 404);
return;
@@ -8878,7 +8935,7 @@ static void _webui_http_send(
const char* mime_type, const char* body, size_t body_len, bool cache) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_http_send([%zu])\n", win->num);
#endif
// Send header
@@ -8891,7 +8948,7 @@ static void _webui_http_send(
static void _webui_http_send_error(struct mg_connection* client, const char* body, int status) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_send_error()\n");
+ _webui_log_debug("[Core]\t\t_webui_http_send_error()\n");
#endif
// [header][body]
@@ -8918,8 +8975,8 @@ static void _webui_http_send_error(struct mg_connection* client, const char* bod
#ifdef WEBUI_LOG
static int _webui_http_log(const struct mg_connection* client, const char* message) {
(void)client;
- printf("[Core]\t\t_webui_http_log()\n");
- printf("[Core]\t\t_webui_http_log() -> Log: %s.\n", message);
+ _webui_log_debug("[Core]\t\t_webui_http_log()\n");
+ _webui_log_debug("[Core]\t\t_webui_http_log() -> Log: %s.\n", message);
return 1;
}
#endif
@@ -8937,7 +8994,7 @@ static int _webui_http_log(const struct mg_connection* client, const char* messa
static void _webui_generate_cookies(char* cookies, size_t length) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_generate_cookies()\n");
+ _webui_log_debug("[Core]\t\t_webui_generate_cookies()\n");
#endif
const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
size_t charset_size = sizeof(charset) - 1;
@@ -8951,7 +9008,7 @@ static void _webui_generate_cookies(char* cookies, size_t length) {
static bool _webui_client_cookies_save(_webui_window_t* win, const char* cookies, size_t* client_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_client_cookies_save()\n");
+ _webui_log_debug("[Core]\t\t_webui_client_cookies_save()\n");
#endif
// [win number][_][cookies]
char win_cookies[WEBUI_COOKIES_BUF];
@@ -8969,7 +9026,7 @@ static bool _webui_client_cookies_save(_webui_window_t* win, const char* cookies
static bool _webui_client_cookies_get_id(_webui_window_t* win, const char* cookies, size_t* client_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_client_cookies_get_id()\n");
+ _webui_log_debug("[Core]\t\t_webui_client_cookies_get_id()\n");
#endif
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
if (_webui.cookies[i] != NULL) {
@@ -8985,7 +9042,7 @@ static bool _webui_client_cookies_get_id(_webui_window_t* win, const char* cooki
static size_t _webui_client_get_id(_webui_window_t* win, struct mg_connection* client) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_client_get_id()\n");
+ _webui_log_debug("[Core]\t\t_webui_client_get_id()\n");
#endif
size_t client_id = 0;
if (_webui.config.use_cookies) {
@@ -8998,7 +9055,7 @@ static size_t _webui_client_get_id(_webui_window_t* win, struct mg_connection* c
// static void _webui_client_cookies_free_all(_webui_window_t* win) {
// #ifdef WEBUI_LOG
-// printf("[Core]\t\t_webui_client_cookies_free_all()\n");
+// _webui_log_debug("[Core]\t\t_webui_client_cookies_free_all()\n");
// #endif
// // [win number]
// char win_num[24];
@@ -9019,7 +9076,7 @@ static size_t _webui_client_get_id(_webui_window_t* win, struct mg_connection* c
// static void _webui_client_cookies_free(_webui_window_t* win, struct mg_connection* client) {
// #ifdef WEBUI_LOG
-// printf("[Core]\t\t_webui_client_cookies_free()\n");
+// _webui_log_debug("[Core]\t\t_webui_client_cookies_free()\n");
// #endif
// char cookies[WEBUI_COOKIES_BUF] = {0};
// _webui_get_cookies(client, cookies);
@@ -9034,7 +9091,7 @@ static size_t _webui_client_get_id(_webui_window_t* win, struct mg_connection* c
static const char* _webui_get_cookies_full(const struct mg_connection* client) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_cookies_full()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_cookies_full()\n");
#endif
const char* header = mg_get_header(client, "Cookie");
if (header != NULL)
@@ -9044,7 +9101,7 @@ static const char* _webui_get_cookies_full(const struct mg_connection* client) {
static void _webui_get_cookies(const struct mg_connection* client, char* buffer) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_cookies()\n");
+ _webui_log_debug("[Core]\t\t_webui_get_cookies()\n");
#endif
const char* header = mg_get_header(client, "Cookie");
if (!_webui_is_empty(header)) {
@@ -9055,7 +9112,7 @@ static void _webui_get_cookies(const struct mg_connection* client, char* buffer)
static int _webui_http_handler(struct mg_connection* client, void * _win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler()\n");
#endif
// Mutex
@@ -9078,7 +9135,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
// GET
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> GET [%s]\n", url);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> GET [%s]\n", url);
#endif
// Cookies
@@ -9089,18 +9146,18 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
char cookies[WEBUI_COOKIES_BUF] = {0};
_webui_get_cookies(client, cookies);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Client cookies [%s]\n", cookies);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Client cookies [%s]\n", cookies);
#endif
// Get client ID based on `webui_auth` cookies
if (_webui_client_cookies_get_id(win, cookies, &client_id)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Client ID found [%zu]\n", client_id);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Client ID found [%zu]\n", client_id);
#endif
client_found = true;
}
#ifdef WEBUI_LOG
else {
- printf("[Core]\t\t_webui_http_handler() -> Client ID not found\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Client ID not found\n");
}
#endif
}
@@ -9110,7 +9167,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
if (!client_found) {
if ((_webui.cookies_single_set[win->num])) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> 403 Forbidden\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> 403 Forbidden\n");
#endif
_webui_http_send_error(client, webui_html_served, 403);
_webui_mutex_unlock(&_webui.mutex_http_handler);
@@ -9127,7 +9184,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
// WebUI Bridge
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> WebUI-Bridge\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> WebUI-Bridge\n");
#endif
// Generate JavaScript bridge
@@ -9141,7 +9198,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
// Non-authorized request to `webui.js`, like requesting twice
// Send 200 (Empty)
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Non-authorized request to webui.js\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Non-authorized request to webui.js\n");
#endif
_webui_http_send(win, client, "application/javascript", "", 0, false);
}
@@ -9151,7 +9208,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
// File already handled by the custom external file handler
// nothing to do now.
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Handled by custom external file handler\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Handled by custom external file handler\n");
#endif
}
else if (strcmp(url, "/") == 0) {
@@ -9163,13 +9220,13 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
// Main HTML
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Embedded Index HTML\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Embedded Index HTML\n");
#endif
#ifdef WEBUI_LOG
- printf("---[ HTML (%zu bytes)]--------------\n", _webui_strlen(win->html));
- printf("%s", win->html);
- printf("\n------------------------------------\n");
+ _webui_log("---[ HTML (%zu bytes)]--------------\n", _webui_strlen(win->html));
+ _webui_log("%s", win->html);
+ _webui_log("\n------------------------------------\n");
#endif
// Send 200
@@ -9190,7 +9247,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
);
if (_webui_file_exist(index_path)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> 302 Redirecting to [%s]\n", index_files[i]);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> 302 Redirecting to [%s]\n", index_files[i]);
#endif
mg_send_http_redirect(client, index_files[i], 302);
_webui_free_mem((void*)index_path);
@@ -9264,7 +9321,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
if (script) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Interpret local script file\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Interpret local script file\n");
#endif
// Serve as a script file to be interpreted by
@@ -9274,7 +9331,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Local file\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Local file\n");
#endif
// Serve as a normal text-based file
@@ -9300,7 +9357,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
char* redirect_url = (char*)_webui_malloc(bf_len);
WEBUI_SN_PRINTF_DYN(redirect_url, redirect_len, "%s%s%s", url, "/", index_files[i]);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> 302 Redirecting to [%s]\n", redirect_url);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> 302 Redirecting to [%s]\n", redirect_url);
#endif
mg_send_http_redirect(client, redirect_url, 302);
_webui_free_mem((void*)redirect_url);
@@ -9322,7 +9379,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
// [invalid]
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Not found\n");
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Not found\n");
#endif
// No file or folder is found at this path
@@ -9337,12 +9394,12 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
} else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> Unknown request method [%s]\n", ri->request_method);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> Unknown request method [%s]\n", ri->request_method);
#endif
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_http_handler() -> HTTP Status Code: %d\n", http_status_code);
+ _webui_log_debug("[Core]\t\t_webui_http_handler() -> HTTP Status Code: %d\n", http_status_code);
#endif
_webui_mutex_unlock(&_webui.mutex_http_handler);
@@ -9352,7 +9409,7 @@ static int _webui_http_handler(struct mg_connection* client, void * _win) {
static int _webui_ws_connect_handler(const struct mg_connection* client, void * _win) {
(void)client;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_connect_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler()\n");
#endif
// Dereference
@@ -9365,8 +9422,8 @@ static int _webui_ws_connect_handler(const struct mg_connection* client, void *
if (_webui_mutex_is_connected(win, WEBUI_MUTEX_GET_STATUS)) {
// Multi-client is disabled, and the single client already connected.
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_connect_handler() -> Single client already connected\n");
- printf("[Core]\t\t_webui_ws_connect_handler() -> Non-authorized connection\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> Single client already connected\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> Non-authorized connection\n");
#endif
// Block handshake
return 1;
@@ -9381,18 +9438,18 @@ static int _webui_ws_connect_handler(const struct mg_connection* client, void *
char cookies[WEBUI_COOKIES_BUF] = {0};
_webui_get_cookies(client, cookies);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_connect_handler() -> Client cookies [%s]\n", cookies);
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> Client cookies [%s]\n", cookies);
#endif
// Get client ID based on `webui_auth` cookies
if (_webui_client_cookies_get_id(win, cookies, &client_id)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_connect_handler() -> Client ID found [%zu]\n", client_id);
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> Client ID found [%zu]\n", client_id);
#endif
client_found = true;
}
#ifdef WEBUI_LOG
else {
- printf("[Core]\t\t_webui_ws_connect_handler() -> Client ID not found\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> Client ID not found\n");
}
#endif
}
@@ -9402,7 +9459,7 @@ static int _webui_ws_connect_handler(const struct mg_connection* client, void *
if (!client_found) {
if ((_webui.cookies_single_set[win->num])) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_connect_handler() -> 403 Forbidden\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> 403 Forbidden\n");
#endif
// Block handshake
return 1;
@@ -9411,7 +9468,7 @@ static int _webui_ws_connect_handler(const struct mg_connection* client, void *
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_connect_handler() -> Connection authentication OK\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_connect_handler() -> Connection authentication OK\n");
#endif
// OK. Process handshake
@@ -9421,7 +9478,7 @@ static int _webui_ws_connect_handler(const struct mg_connection* client, void *
static void _webui_ws_ready_handler(struct mg_connection* client, void * _win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_ready_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_ready_handler()\n");
#endif
// Dereference
@@ -9435,7 +9492,7 @@ static void _webui_ws_ready_handler(struct mg_connection* client, void * _win) {
static int _webui_ws_data_handler(struct mg_connection* client, int opcode, char* data, size_t datasize, void * _win) {
(void)client;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_data_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_data_handler()\n");
#endif
if (_webui_mutex_app_is_exit_now(WEBUI_MUTEX_GET_STATUS) || datasize < WEBUI_PROTOCOL_SIZE)
@@ -9461,7 +9518,7 @@ static int _webui_ws_data_handler(struct mg_connection* client, int opcode, char
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_data_handler() -> Finished\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_data_handler() -> Finished\n");
#endif
// OK
@@ -9471,7 +9528,7 @@ static int _webui_ws_data_handler(struct mg_connection* client, int opcode, char
static void _webui_ws_close_handler(const struct mg_connection* client, void * _win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_close_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_ws_close_handler()\n");
#endif
// Dereference
@@ -9484,7 +9541,7 @@ static void _webui_ws_close_handler(const struct mg_connection* client, void * _
static WEBUI_THREAD_SERVER_START {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread()\n");
+ _webui_log_debug("[Core]\t\t_webui_server_thread()\n");
#endif
// Mutex
@@ -9497,7 +9554,7 @@ static WEBUI_THREAD_SERVER_START {
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread([%zu]) -> URL: [%s]\n", win->num, win->url);
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> URL: [%s]\n", win->num, win->url);
#endif
// Folder monitor thread
@@ -9581,13 +9638,13 @@ static WEBUI_THREAD_SERVER_START {
if (_webui.startup_timeout > 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Listening Success\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Listening Success\n",
win->num);
- printf("[Core]\t\t_webui_server_thread([%zu]) -> HTTP/WS Port: %s\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> HTTP/WS Port: %s\n",
win->num, server_port);
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Root path: %s\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Root path: %s\n",
win->num, win->server_root_path);
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Timeout is %zu seconds\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Timeout is %zu seconds\n",
win->num, _webui.startup_timeout);
#endif
@@ -9601,7 +9658,7 @@ static WEBUI_THREAD_SERVER_START {
// UI is not connected
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_server_thread([%zu]) -> Waiting for connection\n",
win->num
);
@@ -9639,7 +9696,7 @@ static WEBUI_THREAD_SERVER_START {
do {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_server_thread([%zu]) -> Waiting more for connection\n",
win->num
);
@@ -9678,7 +9735,7 @@ static WEBUI_THREAD_SERVER_START {
win->is_closed = false;
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_server_thread([%zu]) -> Window Connected.\n",
win->num
);
@@ -9714,7 +9771,7 @@ static WEBUI_THREAD_SERVER_START {
// The UI is just get disconnected
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_server_thread([%zu]) -> Window disconnected\n",
win->num
);
@@ -9727,7 +9784,7 @@ static WEBUI_THREAD_SERVER_START {
do {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_server_thread([%zu]) -> Waiting for reconnection\n",
win->num
);
@@ -9779,13 +9836,13 @@ static WEBUI_THREAD_SERVER_START {
if (_webui.startup_timeout == 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Listening Success\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Listening Success\n",
win->num);
- printf("[Core]\t\t_webui_server_thread([%zu]) -> HTTP/WS Port: %s\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> HTTP/WS Port: %s\n",
win->num, server_port);
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Root path: %s\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Root path: %s\n",
win->num, win->server_root_path);
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Infinite loop\n",
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Infinite loop\n",
win->num);
#endif
@@ -9812,7 +9869,7 @@ static WEBUI_THREAD_SERVER_START {
} else {
#ifdef WEBUI_LOG
- if (!http_ctx) printf("[Core]\t\t_webui_server_thread([%zu]) -> Listening failed.\n", win->num);
+ if (!http_ctx) _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Listening failed.\n", win->num);
#endif
// Mutex
@@ -9820,7 +9877,7 @@ static WEBUI_THREAD_SERVER_START {
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Cleaning\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Cleaning\n", win->num);
#endif
_webui_mutex_is_connected(win, WEBUI_MUTEX_SET_FALSE);
@@ -9856,7 +9913,7 @@ static WEBUI_THREAD_SERVER_START {
// _webui_client_cookies_free_all(win);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Server stopped.\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Server stopped.\n", win->num);
#endif
// Let the main wait() know that
@@ -9885,7 +9942,7 @@ static WEBUI_THREAD_SERVER_START {
// Clean monitor thread
if (_webui.config.folder_monitor && monitor_created) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_server_thread([%zu]) -> Killing folder monitor thread\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_server_thread([%zu]) -> Killing folder monitor thread\n", win->num);
#endif
#ifdef _WIN32
TerminateThread(monitor_thread, 0);
@@ -9904,7 +9961,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
int event_type, void * data, size_t len) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_receive([%zu], [%d], [%zu])\n", win->num, event_type, len);
+ _webui_log_debug("[Core]\t\t_webui_receive([%zu], [%d], [%zu])\n", win->num, event_type, len);
#endif
static size_t recvNum = 0;
@@ -9919,7 +9976,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
if (!_webui_connection_get_id(win, client, &connection_id)) {
// Failed to find connection ID
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_receive() -> Failed to find connection ID\n");
+ _webui_log_debug("[Core]\t\t_webui_receive() -> Failed to find connection ID\n");
#endif
_webui_connection_remove(win, client);
return;
@@ -9938,7 +9995,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
} else authorization = true;
if (!authorization) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_receive(%zu) -> Connection not authorized to register\n",
+ _webui_log_debug("[Core]\t\t_webui_receive(%zu) -> Connection not authorized to register\n",
recvNum);
#endif
_webui_connection_remove(win, client);
@@ -9950,7 +10007,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
// Update window connection status
_webui_mutex_is_connected(win, WEBUI_MUTEX_SET_TRUE);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_receive(%zu) -> Connection #%zu registered\n",
recvNum, connection_id
);
@@ -9966,7 +10023,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
// Connection close
_webui_connection_remove(win, client);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_receive(%zu) -> Connection #%zu Closed\n",
recvNum, connection_id
);
@@ -9978,7 +10035,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
if ((multi_receive + len) > multi_expect) {
// Received more data than expected
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_receive() -> Multi packet received more data than expected (%zu + %zu > %zu).\n",
multi_receive, len, multi_expect
);
@@ -9992,7 +10049,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
}
// Accumulate packet
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_receive() -> Multi packet accumulate %zu bytes\n", len);
+ _webui_log_debug("[Core]\t\t_webui_receive() -> Multi packet accumulate %zu bytes\n", len);
#endif
memcpy(((unsigned char*)multi_buf + multi_receive), data, len);
multi_receive += len;
@@ -10006,7 +10063,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
size_t expect_len = (size_t) strtoul(&((const char*)data)[WEBUI_PROTOCOL_DATA], NULL, 10);
if (expect_len > 0 && expect_len <= WEBUI_MAX_BUF) {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_receive() -> Multi packet started, Expecting %zu bytes\n",
expect_len
);
@@ -10027,7 +10084,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
size_t arg_len = 0;
if (multi_packet) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_receive() -> Processing multi packet\n");
+ _webui_log_debug("[Core]\t\t_webui_receive() -> Processing multi packet\n");
#endif
// Get data from accumulated multipackets
arg_len = multi_receive;
@@ -10089,7 +10146,7 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client,
static bool _webui_connection_save(_webui_window_t* win, struct mg_connection* client, size_t* connection_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_save([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_connection_save([%zu])\n", win->num);
#endif
// Save new ws client
@@ -10097,7 +10154,7 @@ static bool _webui_connection_save(_webui_window_t* win, struct mg_connection* c
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
if (_webui.clients[i] == NULL) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_save() -> Registering client #%zu \n", i);
+ _webui_log_debug("[Core]\t\t_webui_connection_save() -> Registering client #%zu \n", i);
#endif
// Save
if (win->single_client == NULL) {
@@ -10116,7 +10173,7 @@ static bool _webui_connection_save(_webui_window_t* win, struct mg_connection* c
// List is full
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_save() -> Clients list is full\n");
+ _webui_log_debug("[Core]\t\t_webui_connection_save() -> Clients list is full\n");
#endif
_webui_mutex_unlock(&_webui.mutex_client);
return false;
@@ -10124,7 +10181,7 @@ static bool _webui_connection_save(_webui_window_t* win, struct mg_connection* c
static void _webui_connection_remove(_webui_window_t* win, struct mg_connection* client) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_remove([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_connection_remove([%zu])\n", win->num);
#endif
_webui_mutex_lock(&_webui.mutex_client);
@@ -10133,7 +10190,7 @@ static void _webui_connection_remove(_webui_window_t* win, struct mg_connection*
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
if (_webui.clients[i] == client) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_remove() -> Removing client #%zu \n", i);
+ _webui_log_debug("[Core]\t\t_webui_connection_remove() -> Removing client #%zu \n", i);
#endif
// Reset Token
if (!_webui.config.multi_client) {
@@ -10160,7 +10217,7 @@ static void _webui_connection_remove(_webui_window_t* win, struct mg_connection*
// Client not found
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_remove() -> Client not found\n");
+ _webui_log_debug("[Core]\t\t_webui_connection_remove() -> Client not found\n");
#endif
_webui_mutex_unlock(&_webui.mutex_client);
mg_close_connection(client);
@@ -10168,7 +10225,7 @@ static void _webui_connection_remove(_webui_window_t* win, struct mg_connection*
static bool _webui_connection_get_id(_webui_window_t* win, struct mg_connection* client, size_t* connection_id) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_get_id([%zu], [%p])\n", win->num, client);
+ _webui_log_debug("[Core]\t\t_webui_connection_get_id([%zu], [%p])\n", win->num, client);
#endif
// Find a ws client
@@ -10186,7 +10243,7 @@ static bool _webui_connection_get_id(_webui_window_t* win, struct mg_connection*
// Client not found
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_connection_get_id() -> Client not found\n");
+ _webui_log_debug("[Core]\t\t_webui_connection_get_id() -> Client not found\n");
#endif
return false;
}
@@ -10196,13 +10253,13 @@ static void _webui_ws_process(
void* ptr, size_t len, size_t recvNum, int event_type) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_process(%zu)\n", recvNum);
+ _webui_log_debug("[Core]\t\t_webui_ws_process(%zu)\n", recvNum);
#endif
if (!_webui_mutex_app_is_exit_now(WEBUI_MUTEX_GET_STATUS)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_process(%zu) -> Start\n", recvNum);
+ _webui_log_debug("[Core]\t\t_webui_ws_process(%zu) -> Start\n", recvNum);
#endif
if (event_type == WEBUI_WS_DATA) {
@@ -10212,32 +10269,32 @@ static void _webui_ws_process(
uint16_t packet_id = _webui_get_id(packet);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Data received\n",
recvNum
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Packet Size : %zu bytes\n",
recvNum, len
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Packet Header : [ ",
recvNum
);
_webui_print_hex(packet, WEBUI_PROTOCOL_SIZE);
- printf("]\n");
- printf(
+ _webui_log("]\n");
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Packet Token: 0x%08X (%" PRIu32 ")\n",
recvNum, packet_token, packet_token
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Packet ID: 0x%04X (%u)\n",
recvNum, packet_id, packet_id
);
- printf("[Core]\t\t_webui_ws_process(%zu) -> Packet Data: [", recvNum);
+ _webui_log_debug("[Core]\t\t_webui_ws_process(%zu) -> Packet Data: [", recvNum);
// _webui_print_ascii(&packet[WEBUI_PROTOCOL_DATA], (len -
// WEBUI_PROTOCOL_SIZE));
- printf("]\n");
+ _webui_log("]\n");
#endif
if ((len >= WEBUI_PROTOCOL_SIZE) &&
@@ -10282,7 +10339,7 @@ static void _webui_ws_process(
Y = (int)y;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_process(%zu) -> Drag Window: X = %d (0x%08X), Y = %d (0x%08X)\n", recvNum, X, x, Y, y);
+ _webui_log_debug("[Core]\t\t_webui_ws_process(%zu) -> Drag Window: X = %d (0x%08X), Y = %d (0x%08X)\n", recvNum, X, x, Y, y);
#endif
// Move the dragged window
@@ -10301,15 +10358,15 @@ static void _webui_ws_process(
size_t element_len = _webui_strlen(element);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_CMD_CLICK \n",
recvNum
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Element size: %zu bytes \n",
recvNum, element_len
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Element : [%s] \n",
recvNum, element
);
@@ -10360,28 +10417,28 @@ static void _webui_ws_process(
size_t data_len = len - (WEBUI_PROTOCOL_SIZE + 1 + 1); // [Total packet size - (Header + error byte + null byte)]
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_CMD_JS \n",
recvNum
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> run_id = 0x%02x (%u) \n",
recvNum, packet_id, packet_id
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> error = %s \n",
recvNum, error ? "true" : "false"
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> %zu bytes of data\n",
recvNum, data_len
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> data (Hex) = [",
recvNum
);
_webui_print_hex(data, data_len);
- printf("] @ 0x%p\n", data);
+ _webui_log("] @ 0x%p\n", data);
#endif
// Set pipe
@@ -10423,15 +10480,15 @@ static void _webui_ws_process(
size_t url_len = _webui_strlen(url);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_CMD_NAVIGATION \n",
recvNum
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> URL size: %zu bytes \n",
recvNum, url_len
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> URL: [%s] \n",
recvNum, url
);
@@ -10473,15 +10530,15 @@ static void _webui_ws_process(
size_t element_len = _webui_strlen(element);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_CMD_CALL_FUNC \n",
recvNum
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Call ID: [%u] \n",
recvNum, packet_id
);
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Element: [%s] \n",
recvNum, element
);
@@ -10512,7 +10569,7 @@ static void _webui_ws_process(
}
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Argument %zu: %zu bytes\n",
recvNum, tk_num, arg_len
);
@@ -10535,7 +10592,7 @@ static void _webui_ws_process(
if (data_size_expected == data_size_recv) {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Expected and received %zu bytes of data.\n",
recvNum, data_size_expected
);
@@ -10558,7 +10615,7 @@ static void _webui_ws_process(
// Call user cb
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Calling user callback at address 0x%p\n[Call]\n",
recvNum, win->cb[cb_index]
);
@@ -10569,7 +10626,7 @@ static void _webui_ws_process(
// Async response wait
if (_webui.config.asynchronous_response) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_process(%zu) -> Waiting for asynchronous response...\n", recvNum);
+ _webui_log_debug("[Core]\t\t_webui_ws_process(%zu) -> Waiting for asynchronous response...\n", recvNum);
#endif
bool done = false;
while (!done) {
@@ -10586,7 +10643,7 @@ static void _webui_ws_process(
event_inf->response = NULL;
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> user-callback response [%s]\n",
recvNum, event_inf->response
);
@@ -10609,7 +10666,7 @@ static void _webui_ws_process(
// WebSocket/Civetweb did not send all the data as expected.
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> No enough data received. "
"Expected %zu bytes, received %zu bytes.\n",
recvNum, data_size_expected, data_size_recv
@@ -10639,7 +10696,7 @@ static void _webui_ws_process(
// [Header]
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_CMD_CHECK_TK \n",
recvNum
);
@@ -10654,7 +10711,7 @@ static void _webui_ws_process(
_webui_mutex_is_multi_client_token_valid(win, WEBUI_MUTEX_SET_TRUE, connection_id);
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Token accepted. Sending bind list\n",
recvNum
);
@@ -10731,7 +10788,7 @@ static void _webui_ws_process(
}
else {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Token not accepted.\n",
recvNum
);
@@ -10754,7 +10811,7 @@ static void _webui_ws_process(
}
#ifdef WEBUI_LOG
else {
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Unknown command "
"[0x%02x]\n",
recvNum, (unsigned char)packet[WEBUI_PROTOCOL_CMD]
@@ -10764,7 +10821,7 @@ static void _webui_ws_process(
}
#ifdef WEBUI_LOG
else {
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Window is not connected.\n",
recvNum
);
@@ -10780,7 +10837,7 @@ static void _webui_ws_process(
} else {
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> Invalid Packet.\n",
recvNum
);
@@ -10805,7 +10862,7 @@ static void _webui_ws_process(
// New connection
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_WS_OPEN \n",
recvNum
);
@@ -10840,7 +10897,7 @@ static void _webui_ws_process(
// Connection close
#ifdef WEBUI_LOG
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> WEBUI_WS_CLOSE \n",
recvNum
);
@@ -10871,7 +10928,7 @@ static void _webui_ws_process(
}
#ifdef WEBUI_LOG
else {
- printf(
+ _webui_log(
"[Core]\t\t_webui_ws_process(%zu) -> UNKNOWN EVENT "
"TYPE (%d)\n",
recvNum, event_type
@@ -10880,14 +10937,14 @@ static void _webui_ws_process(
#endif
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_ws_process(%zu) -> Finished.\n", recvNum);
+ _webui_log_debug("[Core]\t\t_webui_ws_process(%zu) -> Finished.\n", recvNum);
#endif
}
}
static WEBUI_THREAD_RECEIVE {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_ws_process_thread()\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_ws_process_thread()\n");
#endif
// Get arguments
@@ -10907,7 +10964,7 @@ static WEBUI_THREAD_RECEIVE {
static void _webui_kill_pid(size_t pid) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_kill_pid(%zu)\n", pid);
+ _webui_log_debug("[Core]\t\t_webui_kill_pid(%zu)\n", pid);
#endif
if (pid < 1)
@@ -10922,7 +10979,7 @@ static void _webui_kill_pid(size_t pid) {
static void _webui_kill_pid(size_t pid) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_kill_pid(%zu)\n", pid);
+ _webui_log_debug("[Core]\t\t_webui_kill_pid(%zu)\n", pid);
#endif
if (pid < 1)
@@ -10948,7 +11005,7 @@ static bool _webui_str_to_wide(const char *s, wchar_t **w) {
static bool _webui_socket_test_listen_win32(size_t port_num) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_socket_test_listen_win32([%zu])\n", port_num);
+ _webui_log_debug("[Core]\t\t_webui_socket_test_listen_win32([%zu])\n", port_num);
#endif
WSADATA wsaData;
@@ -11009,7 +11066,7 @@ static bool _webui_socket_test_listen_win32(size_t port_num) {
static int _webui_system_win32_out(const char* cmd, char ** output, bool show) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_system_win32_out()\n");
+ _webui_log_debug("[Core]\t\t_webui_system_win32_out()\n");
#endif
// Ini
@@ -11114,7 +11171,7 @@ static int _webui_system_win32_out(const char* cmd, char ** output, bool show) {
targetProcessId) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_enum_windows_proc_win32()\n");
+ _webui_log_debug("[Core]\t\t_webui_enum_windows_proc_win32()\n");
#endif
DWORD windowProcessId;
@@ -11123,7 +11180,7 @@ static int _webui_system_win32_out(const char* cmd, char ** output, bool show) {
if (windowProcessId == targetProcessId) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_enum_windows_proc_win32() -> Bring the"
+ _webui_log_debug("[Core]\t\t_webui_enum_windows_proc_win32() -> Bring the"
"process (%lu) to the front\n", windowProcessId);
#endif
@@ -11139,7 +11196,7 @@ static int _webui_system_win32_out(const char* cmd, char ** output, bool show) {
static int _webui_system_win32(_webui_window_t* win, char* cmd, bool show) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_system_win32()\n");
+ _webui_log_debug("[Core]\t\t_webui_system_win32()\n");
#endif
// Convert UTF-8 to wide string
@@ -11213,7 +11270,7 @@ static int _webui_system_win32(_webui_window_t* win, char* cmd, bool show) {
static bool _webui_get_windows_reg_value(HKEY key, LPCWSTR reg, LPCWSTR value_name, char value[WEBUI_MAX_PATH]) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_get_windows_reg_value([%ls])\n", reg);
+ _webui_log_debug("[Core]\t\t_webui_get_windows_reg_value([%ls])\n", reg);
#endif
HKEY hKey;
@@ -11352,7 +11409,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
if (win->close_handler_wv != NULL) {
can_close = win->close_handler_wv(win->num);
#ifdef WEBUI_LOG
- printf("[Core]\t\tClose handler installed for %zu, result = %d\n", win->num, can_close);
+ _webui_log_debug("[Core]\t\tClose handler installed for %zu, result = %d\n", win->num, can_close);
#endif
}
if (can_close) {
@@ -11385,7 +11442,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Close Event
static void _webui_wv_event_closed(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_event_closed([%zu])\n", win->num);
+ _webui_log_debug("[Core]\t\t_webui_wv_event_closed([%zu])\n", win->num);
#endif
win->is_closed = true;
}
@@ -11393,7 +11450,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_show(_webui_window_t* win, char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_wv_show([%s])\n", url);
#endif
// Microsoft Windows WebView2
@@ -11468,7 +11525,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show() -> Return [%d]\n", (_webui.is_webview == true));
+ _webui_log_debug("[Core]\t\t_webui_wv_show() -> Return [%d]\n", (_webui.is_webview == true));
#endif
return (_webui.is_webview);
@@ -11476,7 +11533,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_minimize(_webui_wv_win32_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_minimize()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_minimize()\n");
#endif
if (webView && webView->cpp_handle) {
return _webui_win32_wv2_minimize(webView->cpp_handle);
@@ -11486,7 +11543,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_maximize(_webui_wv_win32_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_maximize()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_maximize()\n");
#endif
if (webView && webView->cpp_handle) {
return _webui_win32_wv2_maximize(webView->cpp_handle);
@@ -11496,7 +11553,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_set_size(_webui_wv_win32_t* webView, int windowWidth, int windowHeight) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_set_size(%d. %d)\n", windowWidth, windowHeight);
+ _webui_log_debug("[Core]\t\t_webui_wv_set_size(%d. %d)\n", windowWidth, windowHeight);
#endif
if (webView && webView->cpp_handle) {
return _webui_win32_wv2_set_size(webView->cpp_handle, windowWidth, windowHeight);
@@ -11506,7 +11563,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_set_position(_webui_wv_win32_t* webView, int x, int y) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_set_position(%d. %d)\n", x, y);
+ _webui_log_debug("[Core]\t\t_webui_wv_set_position(%d. %d)\n", x, y);
#endif
if (webView && webView->cpp_handle) {
return _webui_win32_wv2_set_position(webView->cpp_handle, x, y);
@@ -11516,7 +11573,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_navigate(_webui_wv_win32_t* webView, wchar_t* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_navigate([%ls])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_wv_navigate([%ls])\n", url);
#endif
if (webView && webView->cpp_handle) {
return _webui_win32_wv2_navigate(webView->cpp_handle, url);
@@ -11526,7 +11583,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_free(_webui_wv_win32_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_free()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_free()\n");
#endif
if (webView != NULL) {
if (webView->cpp_handle) {
@@ -11538,7 +11595,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_close(_webui_wv_win32_t *webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_close()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_close()\n");
#endif
(void)webView;
// ...
@@ -11546,7 +11603,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static WEBUI_THREAD_WEBVIEW {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread()\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread()\n");
#endif
_webui_window_t* win = _webui_dereference_win_ptr(arg);
@@ -11726,14 +11783,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Clean
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread() -> Cleaning\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread() -> Cleaning\n");
#endif
_webui_wv_free(win->webView);
_webui_free_mem((void*) cacheFolderW);
win->webView = NULL;
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread() -> End\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread() -> End\n");
#endif
WEBUI_THREAD_RETURN
@@ -11750,7 +11807,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Title Event
static void _webui_wv_event_title(void *web_view, void *pspec, void *arg) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_event_title()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_event_title()\n");
#endif
_webui_window_t* win = (_webui_window_t *)arg;
webkit_web_view_get_title_func webkit_web_view_get_title = (
@@ -11766,7 +11823,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Close Event
static void _webui_wv_event_closed(void *widget, void *arg) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_event_closed()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_event_closed()\n");
#endif
_webui_window_t* win = _webui_dereference_win_ptr(arg);
if (win) {
@@ -11780,14 +11837,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Delete Event (implement on close handling)
static bool _webui_wv_event_on_close(void *widget, void *evt, void *arg) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_event_on_close()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_event_on_close()\n");
#endif
_webui_window_t* win = _webui_dereference_win_ptr(arg);
if (win) {
if (win->close_handler_wv) {
bool can_close = win->close_handler_wv(win->num);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_event_on_close() -> can_close = %d\n", can_close);
+ _webui_log_debug("[Core]\t\t_webui_wv_event_on_close() -> can_close = %d\n", can_close);
#endif
return !can_close;
}
@@ -11797,7 +11854,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_set_size(_webui_wv_linux_t* webView, int windowWidth, int windowHeight) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_set_size(%d. %d)\n", windowWidth, windowHeight);
+ _webui_log_debug("[Core]\t\t_webui_wv_set_size(%d. %d)\n", windowWidth, windowHeight);
#endif
if (webView) {
if (webView->gtk_win) {
@@ -11810,7 +11867,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_minimize(_webui_wv_linux_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_maximize()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_maximize()\n");
#endif
if (webView && webView->gtk_win) {
// gtk_window_iconify(webView->gtk_win);
@@ -11821,7 +11878,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_maximize(_webui_wv_linux_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_maximize()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_maximize()\n");
#endif
if (webView && webView->gtk_win) {
// gtk_window_maximize(webView->gtk_win);
@@ -11832,7 +11889,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_set_position(_webui_wv_linux_t* webView, int x, int y) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_set_position(%d. %d)\n", x, y);
+ _webui_log_debug("[Core]\t\t_webui_wv_set_position(%d. %d)\n", x, y);
#endif
if (webView) {
if (webView->gtk_win) {
@@ -11849,7 +11906,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_navigate(_webui_wv_linux_t* webView, char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_navigate([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_wv_navigate([%s])\n", url);
#endif
if (webView) {
if (webView->gtk_win) {
@@ -11862,7 +11919,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_close(_webui_wv_linux_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_close()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_close()\n");
#endif
if (webView) {
@@ -11872,7 +11929,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
webView->open = false;
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_close() -> Closing WebView window\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_close() -> Closing WebView window\n");
#endif
gtk_window_close(webView->gtk_win);
}
@@ -11884,13 +11941,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_free() {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_free()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_free()\n");
#endif
if (libwebkit) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_free() -> Unload WebKit\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_free() -> Unload WebKit\n");
#endif
dlclose(libwebkit);
}
@@ -11898,7 +11955,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
if (libgtk) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_free() -> Unload GTK\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_free() -> Unload GTK\n");
#endif
dlclose(libgtk);
}
@@ -11911,7 +11968,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_create(_webui_window_t* win) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_create()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_create()\n");
#endif
// Initialize GTK Window
@@ -11969,7 +12026,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static int _webui_wv_create_schedule(void* arg) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_create_schedule()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_create_schedule()\n");
#endif
// This callback is fired by GTK. so it's safe
@@ -11986,13 +12043,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static int _webui_wv_exit_schedule(void* arg) {
#ifdef WEBUI_LOG
- // printf("[Core]\t\t_webui_wv_exit_schedule()\n");
+ // _webui_log_debug("[Core]\t\t_webui_wv_exit_schedule()\n");
#endif
if (_webui_mutex_app_is_exit_now(WEBUI_MUTEX_GET_STATUS)) {
if (_webui.is_gtk_main_run) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_exit_schedule() -> Quit GTK Main Loop...\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_exit_schedule() -> Quit GTK Main Loop...\n");
#endif
gtk_main_quit();
}
@@ -12012,7 +12069,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
libgtk = dlopen(gtk_libs[i], RTLD_LAZY);
if (libgtk) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_load_gtk_and_webkit() -> GTK loaded [%s]\n",
+ _webui_log_debug("[Core]\t\t_webui_load_gtk_and_webkit() -> GTK loaded [%s]\n",
gtk_libs[i]);
#endif
break;
@@ -12030,7 +12087,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
libwebkit = dlopen(webkit_libs[i], RTLD_LAZY);
if (libwebkit) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_load_gtk_and_webkit() -> WebKit loaded [%s]\n",
+ _webui_log_debug("[Core]\t\t_webui_load_gtk_and_webkit() -> WebKit loaded [%s]\n",
webkit_libs[i]);
#endif
break;
@@ -12112,7 +12169,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
)
{
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_load_gtk_and_webkit() -> GTK symbol addresses failed\n");
+ _webui_log_debug("[Core]\t\t_webui_load_gtk_and_webkit() -> GTK symbol addresses failed\n");
#endif
_webui_wv_free();
return false;
@@ -12121,7 +12178,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Check WebView
if (!webkit_web_view_new || !webkit_web_view_load_uri || !webkit_web_view_get_title) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_load_gtk_and_webkit() -> WebKit symbol addresses failed\n");
+ _webui_log_debug("[Core]\t\t_webui_load_gtk_and_webkit() -> WebKit symbol addresses failed\n");
#endif
_webui_wv_free();
return false;
@@ -12138,14 +12195,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_show(_webui_window_t* win, char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_wv_show([%s])\n", url);
#endif
// Linux GTK WebView
#ifdef WEBUI_DYNAMIC
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show() -> WebUI dynamic version does not support Linux WebView\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_show() -> WebUI dynamic version does not support Linux WebView\n");
#endif
return false;
#endif
@@ -12185,7 +12242,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// window in the main thread `webui_wait()`
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show() -> Schedule the creation of the new WebView window\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_show() -> Schedule the creation of the new WebView window\n");
#endif
g_idle_add(_webui_wv_create_schedule, (void*)win);
@@ -12225,7 +12282,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show() -> Return [%d]\n", (_webui.is_webview == true));
+ _webui_log_debug("[Core]\t\t_webui_wv_show() -> Return [%d]\n", (_webui.is_webview == true));
#endif
return (_webui.is_webview);
@@ -12233,7 +12290,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static WEBUI_THREAD_WEBVIEW {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread()\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread()\n");
#endif
_webui_window_t* win = _webui_dereference_win_ptr(arg);
@@ -12255,7 +12312,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
if (win->webView->gtk_win && win->webView->gtk_wv) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread() -> Started\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread() -> Started\n");
#endif
// Success
@@ -12297,7 +12354,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread() -> Cleaning\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread() -> Cleaning\n");
#endif
// Clean
@@ -12305,7 +12362,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
win->webView = NULL;
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread() -> End\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread() -> End\n");
#endif
WEBUI_THREAD_RETURN
@@ -12315,7 +12372,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_set_size(_webui_wv_macos_t* webView, int windowWidth, int windowHeight) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_set_size(%d. %d)\n", windowWidth, windowHeight);
+ _webui_log_debug("[Core]\t\t_webui_wv_set_size(%d. %d)\n", windowWidth, windowHeight);
#endif
_webui_macos_wv_set_size(webView->index, windowWidth, windowHeight);
return false;
@@ -12323,7 +12380,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_minimize(_webui_wv_macos_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_minimize()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_minimize()\n");
#endif
_webui_macos_wv_minimize(webView->index);
return true;
@@ -12331,7 +12388,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_maximize(_webui_wv_macos_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_maximize()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_maximize()\n");
#endif
_webui_macos_wv_maximize(webView->index);
return true;
@@ -12339,7 +12396,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_set_position(_webui_wv_macos_t* webView, int x, int y) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_set_position(%d. %d)\n", x, y);
+ _webui_log_debug("[Core]\t\t_webui_wv_set_position(%d. %d)\n", x, y);
#endif
_webui_macos_wv_set_position(webView->index, x, y);
return false;
@@ -12347,7 +12404,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_navigate(_webui_wv_macos_t* webView, char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_navigate([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_wv_navigate([%s])\n", url);
#endif
_webui_macos_wv_navigate(webView->index, (const char*)url);
return false;
@@ -12355,7 +12412,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_free(_webui_wv_macos_t* webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_free()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_free()\n");
#endif
// ...
_webui_free_mem((void*) webView->url);
@@ -12364,7 +12421,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static void _webui_wv_close(_webui_wv_macos_t *webView) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_close()\n");
+ _webui_log_debug("[Core]\t\t_webui_wv_close()\n");
#endif
// ...
}
@@ -12372,7 +12429,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
// Close Event
static void _webui_wv_event_closed(int index) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_event_closed([%d])\n", index);
+ _webui_log_debug("[Core]\t\t_webui_wv_event_closed([%d])\n", index);
#endif
if (_webui.wins[index] != NULL) {
_webui.wins[index]->is_closed = true;
@@ -12395,7 +12452,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static bool _webui_wv_show(_webui_window_t* win, char* url) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_wv_show([%s])\n", url);
+ _webui_log_debug("[Core]\t\t_webui_wv_show([%s])\n", url);
#endif
// Apple macOS WKWebView
@@ -12481,7 +12538,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static WEBUI_THREAD_WEBVIEW {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread()\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread()\n");
#endif
_webui_window_t* win = _webui_dereference_win_ptr(arg);
@@ -12545,7 +12602,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
win->webView = NULL;
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_webview_thread() -> End\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_webview_thread() -> End\n");
#endif
WEBUI_THREAD_RETURN
@@ -12555,7 +12612,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
static WEBUI_THREAD_MONITOR {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread()\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread()\n");
#endif
_webui_window_t* win = _webui_dereference_win_ptr(arg);
@@ -12582,14 +12639,14 @@ static WEBUI_THREAD_MONITOR {
);
if (hDir == INVALID_HANDLE_VALUE) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Failed to open folder: %s\n",
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Failed to open folder: %s\n",
win->server_root_path
);
#endif
WEBUI_THREAD_RETURN
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Monitoring [%s]\n", win->server_root_path);
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Monitoring [%s]\n", win->server_root_path);
#endif
char buffer[1024];
DWORD bytesReturned;
@@ -12601,7 +12658,7 @@ static WEBUI_THREAD_MONITOR {
))
{
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Folder updated\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Folder updated\n");
#endif
// Loop trough all connected clients in this window
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
@@ -12612,7 +12669,7 @@ static WEBUI_THREAD_MONITOR {
}
} else {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Failed to read folder changes\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Failed to read folder changes\n");
#endif
break;
}
@@ -12623,27 +12680,27 @@ static WEBUI_THREAD_MONITOR {
int fd = inotify_init();
if (fd < 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> inotify_init error\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> inotify_init error\n");
#endif
WEBUI_THREAD_RETURN
}
int wd = inotify_add_watch(fd, win->server_root_path, IN_MODIFY | IN_CREATE | IN_DELETE);
if (wd < 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> inotify_add_watch error\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> inotify_add_watch error\n");
#endif
close(fd);
WEBUI_THREAD_RETURN
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Monitoring [%s]\n", win->server_root_path);
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Monitoring [%s]\n", win->server_root_path);
#endif
char buffer[1024];
while (!_webui_mutex_app_is_exit_now(WEBUI_MUTEX_GET_STATUS)) {
int length = read(fd, buffer, sizeof(buffer));
if (length < 0) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> read error\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> read error\n");
#endif
break;
}
@@ -12653,7 +12710,7 @@ static WEBUI_THREAD_MONITOR {
if (event->len) {
if (event->mask&(IN_CREATE | IN_DELETE | IN_MODIFY)) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Folder updated\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Folder updated\n");
#endif
// Loop trough all connected clients in this window
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
@@ -12674,20 +12731,20 @@ static WEBUI_THREAD_MONITOR {
int kq = kqueue();
if (kq == -1) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> kqueue error\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> kqueue error\n");
#endif
WEBUI_THREAD_RETURN
}
int fd = open(win->server_root_path, O_RDONLY);
if (fd == -1) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> open error\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> open error\n");
#endif
close(kq);
WEBUI_THREAD_RETURN
}
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Monitoring [%s]\n", win->server_root_path);
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Monitoring [%s]\n", win->server_root_path);
#endif
struct kevent change;
EV_SET(&change, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT, NOTE_WRITE, 0, NULL);
@@ -12696,13 +12753,13 @@ static WEBUI_THREAD_MONITOR {
int nev = kevent(kq, &change, 1, &event, 1, NULL);
if (nev == -1) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> kevent error\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> kevent error\n");
#endif
break;
} else if (nev > 0) {
if (event.fflags&NOTE_WRITE) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Folder updated\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Folder updated\n");
#endif
// Loop trough all connected clients in this window
for (size_t i = 0; i < WEBUI_MAX_IDS; i++) {
@@ -12718,7 +12775,7 @@ static WEBUI_THREAD_MONITOR {
close(kq);
#endif
#ifdef WEBUI_LOG
- printf("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Exit\n");
+ _webui_log_debug("[Core]\t\t[Thread .] _webui_folder_monitor_thread() -> Exit\n");
#endif
WEBUI_THREAD_RETURN
}
@@ -12726,7 +12783,7 @@ static WEBUI_THREAD_MONITOR {
static void _webui_bridge_api_handler(webui_event_t* e) {
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_bridge_api_handler()\n");
+ _webui_log_debug("[Core]\t\t_webui_bridge_api_handler()\n");
#endif
// This function gets called by `webui.js` to reach
@@ -12734,7 +12791,7 @@ static void _webui_bridge_api_handler(webui_event_t* e) {
const char* api_name = webui_get_string(e);
#ifdef WEBUI_LOG
- printf("[Core]\t\t_webui_bridge_api_handler() -> api_name: [%s]\n", api_name);
+ _webui_log_debug("[Core]\t\t_webui_bridge_api_handler() -> api_name: [%s]\n", api_name);
#endif
if (strcmp(api_name, "high_contrast") == 0) {