general/log.h

Go to the documentation of this file.
00001 /* $Id: log.h jjs $ */
00002 /*
00003    Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
00004    Part of the Moros Project http://moros.sourceforge.net/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY.
00010 
00011    See the COPYING file for more details.
00012 */
00013 
00014 #ifndef __LOG_H
00015 #define __LOG_H
00016 
00026 
00027 
00031 void dbg_init(const char *file);
00032 
00034 
00042 void dbg_log(const int prio, const char *routine, const char *format, ...);
00043 
00045 
00051 void dbg_level(const int prio, const char *routine);
00052 
00053 #define DEBUG_ERROR 0
00054 #define DEBUG_STATE 1
00055 #define DEBUG_COMM 2
00056 #define DEBUG_DATA 3
00057 #define DEBUG_CALLS 4
00058 
00060 
00061 #ifndef DEBUG_LEVEL
00062     #define DEBUG_LEVEL DEBUG_CALLS
00063 #endif
00064 
00065 #ifndef DEBUG_ROUTINE
00066     #define DEBUG_ROUTINE "unknown"
00067 #endif
00068 
00070 
00071 #define dbg_error(...) dbg_log(DEBUG_ERROR, DEBUG_ROUTINE, __VA_ARGS__)
00072 #define dbg_fatal(...) { dbg_log(DEBUG_ERROR, DEBUG_ROUTINE, __VA_ARGS__); exit(1); }
00073 
00075 
00076 #if DEBUG_LEVEL >= DEBUG_STATE
00077     #define dbg_state(...) dbg_log(DEBUG_STATE, DEBUG_ROUTINE, __VA_ARGS__)
00078 #else
00079     #define dgb_state(...)
00080 #endif
00081 
00083 
00084 #if DEBUG_LEVEL >= DEBUG_COMM
00085     #define dbg_comm(...) dbg_log(DEBUG_COMM, DEBUG_ROUTINE, __VA_ARGS__)
00086 #else
00087     #define dbg_comm(...)
00088 #endif
00089 
00091 
00092 #if DEBUG_LEVEL >= DEBUG_DATA
00093     #define dbg_data(...) dbg_log(DEBUG_DATA, DEBUG_ROUTINE, __VA_ARGS__)
00094 #else
00095     #define dbg_data(...)
00096 #endif
00097 
00099 
00100 #if DEBUG_LEVEL >= DEBUG_CALLS
00101     #define dbg_calls(...) dbg_log(DEBUG_CALLS, DEBUG_ROUTINE, __VA_ARGS__)
00102 #else
00103     #define dbg_calls(...)
00104 #endif
00105 
00106 #endif // __LOG_H


Generated on Tue Jan 1 17:30:00 2008 for general/log.h Source File by  doxygen   Visit the project page on SourceForge.net Logo