From 1a41e7b2976c6486eb1412c55ed98c7fcc9f3e51 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 16 Sep 2020 16:33:22 +0200 Subject: [PATCH] added option to limit debug output to specific debug mode --- src/libgame/misc.c | 10 ++++++++++ src/libgame/system.h | 1 + src/main.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 17072d87..7047ba92 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -331,6 +331,11 @@ void Debug(char *mode, char *format, ...) { va_list ap; + // if optional debug mode specified, limit debug output accordingly + if (options.debug_mode != NULL && + !strEqual(options.debug_mode, mode)) + return; + va_start(ap, format); Log(LOG_DEBUG, mode, format, ap); va_end(ap); @@ -1036,6 +1041,7 @@ void GetOptions(int argc, char *argv[], options.execute_command = NULL; options.special_flags = NULL; + options.debug_mode = NULL; options.mytapes = FALSE; options.serveronly = FALSE; @@ -1170,6 +1176,10 @@ void GetOptions(int argc, char *argv[], else if (strncmp(option, "-debug", option_len) == 0) { options.debug = TRUE; + + // optionally, debug output can be limited to a specific debug mode + if (option_arg != next_option) + options.debug_mode = getStringCopy(option_arg); } else if (strncmp(option, "-verbose", option_len) == 0) { diff --git a/src/libgame/system.h b/src/libgame/system.h index 6e0296ef..d18f0f27 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1001,6 +1001,7 @@ struct OptionInfo char *execute_command; char *special_flags; + char *debug_mode; boolean mytapes; boolean serveronly; diff --git a/src/main.c b/src/main.c index ca4be86d..86cd3099 100644 --- a/src/main.c +++ b/src/main.c @@ -7621,7 +7621,7 @@ static void print_usage(void) " --serveronly only start network server\n" " -v, --verbose verbose mode\n" " -V, --version show program version\n" - " --debug display debugging information\n" + " --debug[=MODE] show (and limit) debug output\n" " -e, --execute COMMAND execute batch COMMAND\n" "\n" "Valid commands for '--execute' option:\n" -- 2.34.1