diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index cf6122b158..00f7a7670e 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -155,7 +155,7 @@ void debug_filter_clear() tags[i] = 0; } -static bool filter_allows(const char* text) +bool debug_filter_allows(const char* text) { uint i; for(i = 0; ; i++) @@ -187,7 +187,7 @@ void debug_printf(const char* fmt, ...) vsnprintf(buf, MAX_CHARS-1, fmt, ap); va_end(ap); - if(filter_allows(buf)) + if(debug_filter_allows(buf)) debug_puts(buf); } @@ -224,7 +224,7 @@ void debug_wprintf(const wchar_t* fmt, ...) // .. paranoia: overflow is impossible debug_assert(bytes_written <= MAX_BYTES); - if(filter_allows(mbs_buf)) + if(debug_filter_allows(mbs_buf)) debug_puts(mbs_buf); } diff --git a/source/lib/debug.h b/source/lib/debug.h index db62cf6e5c..b8d7e1fcc7 100644 --- a/source/lib/debug.h +++ b/source/lib/debug.h @@ -253,7 +253,7 @@ extern ErrorReaction debug_display_error(const wchar_t* description, * we don't want to require different LOGn() macros that are enabled * depending on "debug level", because changing that entails lengthy * compiles and it's too coarse-grained. instead, we require all - * strings to start with "tag_string:" (exact case and no quotes; + * strings to start with "tag_string|" (exact case and no quotes; * the alphanumeric-only identifies output type). * they are then subject to filtering: only if the tag has been * "added" via debug_filter_add is the appendant string displayed. @@ -285,6 +285,13 @@ extern void debug_filter_remove(const char* tag); **/ extern void debug_filter_clear(); +/** + * indicate if the given text would be printed. + * useful for a series of debug_printfs - avoids needing to add a tag to + * each of their format strings. + **/ +extern bool debug_filter_allows(const char* text); + /** * write to memory buffer (fast) diff --git a/source/lib/res/file/file_stats.cpp b/source/lib/res/file/file_stats.cpp index 94ac177354..a95e20b381 100644 --- a/source/lib/res/file/file_stats.cpp +++ b/source/lib/res/file/file_stats.cpp @@ -288,6 +288,9 @@ template int percent(T num, T divisor) void file_stats_dump() { + if(!debug_filter_allows("FILE_STATS|")) + return; + const double KB = 1e3; const double MB = 1e6; const double ms = 1e-3; debug_printf("--------------------------------------------------------------------------------\n");