From: Holger Schemel Date: Wed, 16 Sep 2020 14:33:22 +0000 (+0200) Subject: added option to limit debug output to specific debug mode X-Git-Tag: 4.2.0.3~37 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1a41e7b2976c6486eb1412c55ed98c7fcc9f3e51;p=rocksndiamonds.git added option to limit debug output to specific debug mode --- 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"