Changeset - r16081:e554542808c8
[Not reviewed]
master
0 2 0
alberth - 14 years ago 2010-09-11 11:48:37
alberth@openttd.org
(svn r20784) -Doc: Doxyment a few debug line printing functions.
2 files changed with 24 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/debug.cpp
Show inline comments
 
@@ -66,12 +66,17 @@ struct DebugLevel {
 
	DEBUG_LEVEL(console),
 
	};
 
#undef DEBUG_LEVEL
 

	
 
#if !defined(NO_DEBUG_MESSAGES)
 

	
 
/**
 
 * Internal function for outputting the debug line.
 
 * @param dbg Debug category.
 
 * @param buf Text line to output.
 
 */
 
static void debug_print(const char *dbg, const char *buf)
 
{
 
#if defined(ENABLE_NETWORK)
 
	if (_debug_socket != INVALID_SOCKET) {
 
		char buf2[1024 + 32];
 

	
 
@@ -96,12 +101,18 @@ static void debug_print(const char *dbg,
 

	
 
		fprintf(f, "%s%s\n", GetLogPrefix(), buf);
 
		fflush(f);
 
	}
 
}
 

	
 
/**
 
 * 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);
 
@@ -109,12 +120,18 @@ void CDECL debug(const char *dbg, const 
 
	va_end(va);
 

	
 
	debug_print(dbg, buf);
 
}
 
#endif /* NO_DEBUG_MESSAGES */
 

	
 
/**
 
 * 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)
 
{
 
	int v;
 
	char *end;
 
	const char *t;
 

	
 
@@ -159,14 +176,14 @@ void SetDebugString(const char *s)
 
			return;
 
		}
 
	}
 
}
 

	
 
/**
 
 * Print out the current debug-level
 
 * Just return a string with the values of all the debug categorites
 
 * Print out the current debug-level.
 
 * Just return a string with the values of all the debug categories.
 
 * @return string with debug-levels
 
 */
 
const char *GetDebugString()
 
{
 
	const DebugLevel *i;
 
	static char dbgstr[150];
src/debug.h
Show inline comments
 
@@ -26,12 +26,17 @@
 
 * 6.. - extremely detailed spamming
 
 */
 

	
 
#ifdef NO_DEBUG_MESSAGES
 
	#define DEBUG(name, level, ...) { }
 
#else /* NO_DEBUG_MESSAGES */
 
	/**
 
	 * 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_ai_level;
 
	extern int _debug_driver_level;
 
	extern int _debug_grf_level;
 
	extern int _debug_map_level;
0 comments (0 inline, 0 general)