diff options
author | Darkvater <darkvater@openttd.org> | 2006-12-26 17:36:18 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-12-26 17:36:18 +0000 |
commit | 073e0eb3c9148d6dd8b2c9ce788843b8180351cb (patch) | |
tree | 8dae47833ded5c522ac7a89f69f10fc0c2530e90 /debug.h | |
parent | 2e0bbe540383c96f4356dd75e70bb1fa5c8e95be (diff) | |
download | openttd-073e0eb3c9148d6dd8b2c9ce788843b8180351cb.tar.xz |
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
use in debug.h. grfmsg() is now used as a specific debug-function for grf.
Diffstat (limited to 'debug.h')
-rw-r--r-- | debug.h | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -3,10 +3,24 @@ #ifndef DEBUG_H #define DEBUG_H +/* Debugging messages policy: + * 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 + * 3 - important debugging messages (function entry) + * 4 - debugging messages (crude loop status, etc.) + * 5 - detailed debugging information + * 6.. - extremely detailed spamming + */ + #ifdef NO_DEBUG_MESSAGES - #define DEBUG(name, level) + #define DEBUG(name, level, ...) #else - #define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug + #define DEBUG(name, level, ...) if (level == 0 || _debug_ ## name ## _level >= level) debug(#name, __VA_ARGS__) extern int _debug_ai_level; extern int _debug_driver_level; @@ -15,15 +29,16 @@ extern int _debug_misc_level; extern int _debug_ms_level; extern int _debug_net_level; - extern int _debug_spritecache_level; + extern int _debug_sprite_level; extern int _debug_oldloader_level; extern int _debug_ntp_level; extern int _debug_npf_level; extern int _debug_yapf_level; extern int _debug_freetype_level; + extern int _debug_sl_level; #endif -void CDECL debug(const char *s, ...); +void CDECL debug(const char *dbg, ...); void SetDebugString(const char *s); const char *GetDebugString(void); @@ -45,7 +60,7 @@ const char *GetDebugString(void); #define TOC(str, count)\ __sum__ += _rdtsc() - _xxx_;\ if (++__i__ == count) {\ - printf("[%s]: %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ + DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ __i__ = 0;\ __sum__ = 0;\ }\ |