From 0fbc9660d8def8b085d5fbdbcad1faddd00cb0b6 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 23 Jul 2026 22:45:26 +0300 Subject: [PATCH] =?UTF-8?q?chatgui:=20unify=20logging=20=E2=80=94=20debug?= =?UTF-8?q?=5Fui.h=20delegates=20to=20debug=5Fconfig.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit debug_ui.h (50→10 lines): GUI_ERROR/WARN/INFO/DEBUG now delegate to DEBUG_ERROR/WARN/INFO/DEBUG(DEBUG_CATEGORY_DEBUG, ...) from debug_config.h Eliminates dual logging output, dual log file configuration. Removed guiDebugFile() — debug_enable_file_output() already handles it. Removed debug_ui.h include from utun_node.cpp (unused). --- tools/chatgui/src/debug_ui.h | 52 ++++----------------------- tools/chatgui/transport/utun_node.cpp | 2 -- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/tools/chatgui/src/debug_ui.h b/tools/chatgui/src/debug_ui.h index 039c1b8f5..8ec0108b5 100644 --- a/tools/chatgui/src/debug_ui.h +++ b/tools/chatgui/src/debug_ui.h @@ -1,50 +1,10 @@ #pragma once -#if !defined(GUI_DEBUG_DISABLE) - -#include -#include -#include - -namespace GuiDebugPriv { - inline FILE *s_file = stderr; - - inline void setFile(const char *path) { - if (s_file && s_file != stderr) fclose(s_file); - s_file = path ? fopen(path, "a") : nullptr; - if (!s_file) s_file = stderr; - } +extern "C" { +#include "../../lib/debug_config.h" } -inline void guiDebugFile(const char *path) { GuiDebugPriv::setFile(path); } - -inline void guiDebugLog(char lvl, const char *file, int line, - const char *func, const char *fmt, ...) { - const char *base = strrchr(file, '/'); - if (!base) base = strrchr(file, '\\'); - if (GuiDebugPriv::s_file != stderr) - fprintf(GuiDebugPriv::s_file, "[1] "); - fprintf(GuiDebugPriv::s_file, "[%c] %s:%d %s(): ", - lvl, base ? base + 1 : file, line, func); - va_list ap; - va_start(ap, fmt); - vfprintf(GuiDebugPriv::s_file, fmt, ap); - va_end(ap); - fprintf(GuiDebugPriv::s_file, "\n"); - fflush(GuiDebugPriv::s_file); -} - -#define GUI_ERROR(fmt, ...) guiDebugLog('E', __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__) -#define GUI_WARN(fmt, ...) guiDebugLog('W', __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__) -#define GUI_INFO(fmt, ...) guiDebugLog('I', __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__) -#define GUI_DEBUG(fmt, ...) guiDebugLog('D', __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__) - -#else - -inline void guiDebugFile(const char*) {} -#define GUI_ERROR(...) ((void)0) -#define GUI_WARN(...) ((void)0) -#define GUI_INFO(...) ((void)0) -#define GUI_DEBUG(...) ((void)0) - -#endif +#define GUI_ERROR(fmt, ...) DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, fmt, ##__VA_ARGS__) +#define GUI_WARN(fmt, ...) DEBUG_WARN(DEBUG_CATEGORY_DEBUG, fmt, ##__VA_ARGS__) +#define GUI_INFO(fmt, ...) DEBUG_INFO(DEBUG_CATEGORY_DEBUG, fmt, ##__VA_ARGS__) +#define GUI_DEBUG(fmt, ...) DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, fmt, ##__VA_ARGS__) diff --git a/tools/chatgui/transport/utun_node.cpp b/tools/chatgui/transport/utun_node.cpp index e56b5923c..535258777 100644 --- a/tools/chatgui/transport/utun_node.cpp +++ b/tools/chatgui/transport/utun_node.cpp @@ -5,7 +5,6 @@ #include "../../lib/socket_compat.h" #include "../db/db_manager.h" -#include "../src/debug_ui.h" // === C headers === extern "C" { @@ -249,7 +248,6 @@ void UtunNode::runLoop() { debug_enable_file_output(m_debugFile.toUtf8().constData(), 0); debug_enable_console(1); g_debug_config.thread_marker = 2; - guiDebugFile(m_debugFile.toUtf8().constData()); } utun_instance_set_tun_init_enabled(0);