debug: single source of truth for category names, GUI dynamic labels

- debug_get_category_name(): replace switch/case with table lookup in g_debug_categories[]
- etcpmon_gui: remove hardcoded cat_names[], create labels/radios dynamically from server CSV
This commit is contained in:
Evgeny committed 2026-06-11 10:16:14 +03:00
1 parent 6b2b0f1360
commit 3419ff3a85
2 files changed
+44 -49

No files matched your search

+3 -26
View File
@@ -199,32 +199,9 @@ void debug_apply_global_level(const char* level_name) {
/* Get category name for logging */
const char* debug_get_category_name(debug_category_t category_idx) {
switch (category_idx) {
case DEBUG_CATEGORY_UASYNC: return "UASYNC";
case DEBUG_CATEGORY_LL_QUEUE: return "LL_QUEUE";
case DEBUG_CATEGORY_CONNECTION: return "CONNECTION";
case DEBUG_CATEGORY_ETCP: return "ETCP";
case DEBUG_CATEGORY_CRYPTO: return "CRYPTO";
case DEBUG_CATEGORY_MEMORY: return "MEMORY";
case DEBUG_CATEGORY_TIMING: return "TIMING";
case DEBUG_CATEGORY_CONFIG: return "CONFIG";
case DEBUG_CATEGORY_TUN: return "TUN";
case DEBUG_CATEGORY_ROUTING: return "ROUTING";
case DEBUG_CATEGORY_TIMERS: return "TIMERS";
case DEBUG_CATEGORY_NORMALIZER: return "NORMALIZER";
case DEBUG_CATEGORY_BGP: return "BGP";
case DEBUG_CATEGORY_SOCKET: return "SOCKET";
case DEBUG_CATEGORY_CONTROL: return "CONTROL";
case DEBUG_CATEGORY_DUMP: return "DUMP";
case DEBUG_CATEGORY_TRAFFIC: return "TRAFFIC";
case DEBUG_CATEGORY_DEBUG: return "DEBUG";
case DEBUG_CATEGORY_GENERAL: return "GENERAL";
case DEBUG_CATEGORY_NAT: return "NAT";
case DEBUG_CATEGORY_KEEPALIVE: return "KEEPALIVE";
case DEBUG_CATEGORY_ETCPROUTE: return "ETCPROUTE";
case DEBUG_CATEGORY_NONE: return "NONE";
default: return "UNKNOWN";
}
for (int i = 0; g_debug_categories[i].name; i++)
if (g_debug_categories[i].category == category_idx) return g_debug_categories[i].name;
return "UNKNOWN";
}
/* Global debug configuration */