Changeset - r25656:3bd4befea0c4
[Not reviewed]
master
0 2 0
rubidium42 - 3 years ago 2021-06-12 09:21:41
rubidium@openttd.org
Cleanup: remove old DEBUG macro and debug function
2 files changed with 1 insertions and 28 deletions:
0 comments (0 inline, 0 general)
src/debug.cpp
Show inline comments
 
@@ -141,30 +141,12 @@ void debug_print(const char *dbg, const 
 
		NetworkAdminConsole(dbg, buf);
 
		IConsoleDebug(dbg, buf);
 
	}
 
}
 

	
 
/**
 
 * Output a debug line.
 
 * @note Do not call directly, use the #DEBUG macro instead.
 
 * @param dbg Debug category.
 
 * @param format Text string a la printf, with optional arguments.
 
 */
 
void CDECL debug(const char *dbg, const char *format, ...)
 
{
 
	char buf[1024];
 

	
 
	va_list va;
 
	va_start(va, format);
 
	vseprintf(buf, lastof(buf), format, va);
 
	va_end(va);
 

	
 
	debug_print(dbg, buf);
 
}
 

	
 
/**
 
 * Set debugging levels by parsing the text in \a s.
 
 * For setting individual levels a string like \c "net=3,grf=6" should be used.
 
 * If the string starts with a number, the number is used as global debugging level.
 
 * @param s Text describing the wanted debugging levels.
 
 */
 
void SetDebugString(const char *s)
src/debug.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "cpu.h"
 
#include <chrono>
 
#include "3rdparty/fmt/format.h"
 

	
 
/* Debugging messages policy:
 
 * These should be the severities used for direct DEBUG() calls
 
 * These should be the severities used for direct Debug() calls
 
 * maximum debugging level should be 10 if really deep, deep
 
 * debugging is needed.
 
 * (there is room for exceptions, but you have to have a good cause):
 
 * 0   - errors or severe warnings
 
 * 1   - other non-fatal, non-severe warnings
 
 * 2   - crude progress indicator of functionality
 
@@ -35,19 +35,12 @@ void debug_print(const char *dbg, const 
 
 * @param name The category of debug information.
 
 * @param level The maximum debug level this message should be shown at. When the debug level for this category is set lower, then the message will not be shown.
 
 * @param format_string The formatting string of the message.
 
 */
 
#define Debug(name, level, format_string, ...) if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug_print(#name, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__).c_str())
 

	
 
/**
 
 * Output a line of debugging information.
 
 * @param name Category
 
 * @param level Debugging level, higher levels means more detailed information.
 
 */
 
#define DEBUG(name, level, ...) if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug(#name, __VA_ARGS__)
 

	
 
extern int _debug_driver_level;
 
extern int _debug_grf_level;
 
extern int _debug_map_level;
 
extern int _debug_misc_level;
 
extern int _debug_net_level;
 
extern int _debug_sprite_level;
 
@@ -61,14 +54,12 @@ extern int _debug_gamelog_level;
 
extern int _debug_desync_level;
 
extern int _debug_console_level;
 
#ifdef RANDOM_DEBUG
 
extern int _debug_random_level;
 
#endif
 

	
 
void CDECL debug(const char *dbg, const char *format, ...) WARN_FORMAT(2, 3);
 

	
 
char *DumpDebugFacilityNames(char *buf, char *last);
 
void SetDebugString(const char *s);
 
const char *GetDebugString();
 

	
 
/* Shorter form for passing filename and linenumber */
 
#define FILE_LINE __FILE__, __LINE__
0 comments (0 inline, 0 general)