chatgui: unify logging — debug_ui.h delegates to debug_config.h
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).
This commit is contained in:
1 parent
7bee785547
commit
0fbc9660d8
2 files changed
+6
-48
No files matched your search
@@ -1,50 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#if !defined(GUI_DEBUG_DISABLE)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
|
||||
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__)
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user