- debug_ui.h: remove NDEBUG guard so GUI_ERROR works in Release builds - invite_link.h/cpp: add error field to InviteData with specific failure reason - joindialog: show exact decode error in QLabel instead of generic message - chat_sync: implement invite connect flow (CHANNEL_INFO_REQ/RESP, JOIN, WELCOME) - topo_node_sqlite: node/address table init and lookup - utun_node: getInviteAddresses fallback from ETCP sockets - minor fixes in mainwindow, chat_core, gui_bridge
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
#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;
|
|
}
|
|
}
|
|
|
|
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
|