diff --git a/lib/debug_config.c b/lib/debug_config.c index a9a29d91..f0d1fa87 100644 --- a/lib/debug_config.c +++ b/lib/debug_config.c @@ -223,8 +223,6 @@ void debug_config_init(void) { // Dual output defaults g_debug_config.file_output = NULL; // No file by default - g_debug_config.file_level = DEBUG_LEVEL_TRACE; // File gets everything - g_debug_config.console_level = DEBUG_LEVEL_INFO; // Console gets INFO+ g_debug_config.console_enabled = 1; // Console enabled g_debug_config.thread_marker = 0; // No thread marker by default } @@ -232,7 +230,6 @@ void debug_config_init(void) { /* Set debug level */ void debug_set_level(debug_level_t level) { g_debug_config.level = level; - g_debug_config.console_level = level; } /* Set debug level for specific category (0 = disabled, otherwise uses that level) */ @@ -284,16 +281,6 @@ void debug_set_output_file(const char* file_path) { } /* Set console log level */ -void debug_set_console_level(debug_level_t level) { - g_debug_config.console_level = level; -} - -/* Set file log level */ -void debug_set_file_level(debug_level_t level) { - g_debug_config.file_level = level; -} - -/* Enable/disable console output */ void debug_enable_console(int enable) { g_debug_config.console_enabled = enable; } @@ -446,15 +433,12 @@ void debug_output(debug_level_t level, debug_category_t category_idx, va_end(args); /* Output to console if enabled and level is sufficient */ - if (g_debug_config.console_enabled && level <= g_debug_config.console_level) { - fprintf(stdout, "%s", buffer); - fflush(stdout); - } - - /* Output to file if open and level is sufficient */ - if (g_debug_config.file_output && level <= g_debug_config.file_level) { + if (g_debug_config.file_output) { fprintf(g_debug_config.file_output, "%s", buffer); fflush(g_debug_config.file_output); + } else if (g_debug_config.console_enabled) { + fprintf(stdout, "%s", buffer); + fflush(stdout); } #undef BUFFER_SIZE } diff --git a/lib/debug_config.h b/lib/debug_config.h index 0cd34b8c..176721a5 100644 --- a/lib/debug_config.h +++ b/lib/debug_config.h @@ -78,8 +78,6 @@ typedef struct { // Dual output support FILE* file_output; // File handle for log file (NULL if not open) - debug_level_t file_level; // Log level for file output - debug_level_t console_level; // Log level for console output int console_enabled; // Enable console output int thread_marker; // Thread identification (0=none, e.g. 2 for uasync) } debug_config_t; @@ -111,10 +109,8 @@ void debug_enable_function_name(int enable); void debug_enable_file_line(int enable); void debug_set_output_file(const char* file_path); -/* Dual output configuration */ -void debug_set_console_level(debug_level_t level); -void debug_set_file_level(debug_level_t level); -void debug_enable_file_output(const char* file_path, int truncate); +/* Dual output configuration */ +void debug_enable_file_output(const char* file_path, int truncate); void debug_disable_file_output(void); int debug_reopen_log(void); void debug_enable_console(int enable); diff --git a/tests/test_lwip_tcp.c b/tests/test_lwip_tcp.c index 8441b887..77c78964 100644 --- a/tests/test_lwip_tcp.c +++ b/tests/test_lwip_tcp.c @@ -629,7 +629,7 @@ int main(int argc, char *argv[]) srand(seed); printf("seed=%u\n", seed); debug_config_init(); - debug_set_console_level(DEBUG_LEVEL_NONE); + g_debug_config.console_enabled = 0; debug_set_category_level(DEBUG_CATEGORY_ALL, DEBUG_LEVEL_ERROR); #ifndef _WIN32 setlinebuf(stdout); diff --git a/tools/chatgui/transport/utun_node.cpp b/tools/chatgui/transport/utun_node.cpp index 166aafc5..6a86e5e9 100644 --- a/tools/chatgui/transport/utun_node.cpp +++ b/tools/chatgui/transport/utun_node.cpp @@ -163,12 +163,8 @@ void UtunNode::runLoop() { else if (lvl == "debug") dl = DEBUG_LEVEL_DEBUG; else if (lvl == "trace") dl = DEBUG_LEVEL_TRACE; g_debug_config.level = dl; - g_debug_config.console_level = dl; - g_debug_config.file_level = dl; } else { g_debug_config.level = DEBUG_LEVEL_INFO; - g_debug_config.console_level = DEBUG_LEVEL_INFO; - g_debug_config.file_level = DEBUG_LEVEL_INFO; } /* chatgui defaults: suppress spam, verbose for our categories */