00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00046 #ifndef _orxDEBUG_H_
00047 #define _orxDEBUG_H_
00048
00049 #include "orxInclude.h"
00050
00051
00052
00053
00054 #define orxDEBUG_KU32_STATIC_FLAG_NONE 0x00000000
00055
00056 #define orxDEBUG_KU32_STATIC_FLAG_TIMESTAMP 0x00000001
00057 #define orxDEBUG_KU32_STATIC_FLAG_TYPE 0x00000002
00058 #define orxDEBUG_KU32_STATIC_FLAG_TAGGED 0x00000004
00059
00060 #define orxDEBUG_KU32_STATIC_FLAG_FILE 0x00000010
00061 #define orxDEBUG_KU32_STATIC_FLAG_CONSOLE 0x00000020
00062 #define orxDEBUG_KU32_STATIC_FLAG_GRAPHIC 0x00000040
00063
00064 #define orxDEBUG_KU32_STATIC_MASK_DEFAULT 0x00000037
00065
00066 #define orxDEBUG_KU32_STATIC_MASK_USER_ALL 0x0FFFFFFF
00067
00068
00069
00070
00071 #define orxDEBUG_KZ_DEFAULT_DEBUG_FILE "orx-debug.log"
00072 #define orxDEBUG_KZ_DEFAULT_LOG_FILE "orx.log"
00073 #define orxDEBUG_KZ_DEFAULT_LOG_SUFFIX ".log"
00074 #define orxDEBUG_KZ_DEFAULT_DEBUG_SUFFIX "-debug.log"
00075
00076
00077
00078
00079
00080 #ifdef __orxGCC__
00081
00082 #define orxLOG(STRING, ...) \
00083 do \
00084 { \
00085 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \
00086 } while(orxFALSE)
00087
00088 #define orxLOG_CONSOLE(STRING, ...) \
00089 do \
00090 { \
00091 _orxDebug_BackupFlags(); \
00092 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_CONSOLE \
00093 |orxDEBUG_KU32_STATIC_FLAG_TYPE \
00094 |orxDEBUG_KU32_STATIC_FLAG_TIMESTAMP, \
00095 orxDEBUG_KU32_STATIC_MASK_USER_ALL); \
00096 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \
00097 _orxDebug_RestoreFlags(); \
00098 } while(orxFALSE)
00099
00100 #define orxLOG_FILE(STRING, ...) \
00101 do \
00102 { \
00103 _orxDebug_BackupFlags(); \
00104 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_FILE \
00105 |orxDEBUG_KU32_STATIC_FLAG_TYPE \
00106 |orxDEBUG_KU32_STATIC_FLAG_TIMESTAMP, \
00107 orxDEBUG_KU32_STATIC_MASK_USER_ALL); \
00108 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \
00109 _orxDebug_RestoreFlags(); \
00110 } while(orxFALSE)
00111
00112 #else
00113 #ifdef __orxMSVC__
00114
00115 #define orxLOG(STRING, ...) \
00116 do \
00117 { \
00118 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \
00119 } while(orxFALSE)
00120
00121 #define orxLOG_CONSOLE(STRING, ...) \
00122 do \
00123 { \
00124 _orxDebug_BackupFlags(); \
00125 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_CONSOLE \
00126 |orxDEBUG_KU32_STATIC_FLAG_TYPE \
00127 |orxDEBUG_KU32_STATIC_FLAG_TIMESTAMP, \
00128 orxDEBUG_KU32_STATIC_MASK_USER_ALL); \
00129 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \
00130 _orxDebug_RestoreFlags(); \
00131 } while(orxFALSE)
00132
00133 #define orxLOG_FILE(STRING, ...) \
00134 do \
00135 { \
00136 _orxDebug_BackupFlags(); \
00137 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_FILE \
00138 |orxDEBUG_KU32_STATIC_FLAG_TYPE \
00139 |orxDEBUG_KU32_STATIC_FLAG_TIMESTAMP, \
00140 orxDEBUG_KU32_STATIC_MASK_USER_ALL); \
00141 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \
00142 _orxDebug_RestoreFlags(); \
00143 } while(orxFALSE)
00144
00145 #endif
00146 #endif
00147
00148 #define orxDEBUG_INIT() _orxDebug_Init()
00149 #define orxDEBUG_EXIT() _orxDebug_Exit()
00150
00151 #ifdef __orxDEBUG__
00152
00153
00154 #ifdef __orxGCC__
00155 #define orxDEBUG_PRINT(LEVEL, STRING, ...) _orxDebug_Log(LEVEL, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__)
00156 #else
00157 #ifdef __orxMSVC__
00158 #define orxDEBUG_PRINT(LEVEL, STRING, ...) _orxDebug_Log(LEVEL, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__)
00159 #endif
00160 #endif
00161
00162
00163
00164 #define orxDEBUG_FLAG_SET(SET, UNSET) _orxDebug_SetFlags(SET, UNSET)
00165 #define orxDEBUG_FLAG_BACKUP() _orxDebug_BackupFlags()
00166 #define orxDEBUG_FLAG_RESTORE() _orxDebug_RestoreFlags()
00167
00168
00169 #define orxBREAK() _orxDebug_Break()
00170
00171
00172 #define orxDEBUG_SETDEBUGFILE(FILE) _orxDebug_SetDebugFile(FILE)
00173 #define orxDEBUG_SETLOGFILE(FILE) _orxDebug_SetLogFile(FILE)
00174 #define orxDEBUG_SETBASEFILENAME(FILE) \
00175 do \
00176 { \
00177 orxCHAR zBuffer[256]; \
00178 strncpy(zBuffer, FILE, 256); \
00179 strncat(zBuffer, orxDEBUG_KZ_DEFAULT_DEBUG_SUFFIX, 256);\
00180 _orxDebug_SetDebugFile(zBuffer); \
00181 strncpy(zBuffer, FILE, 256); \
00182 strncat(zBuffer, orxDEBUG_KZ_DEFAULT_LOG_SUFFIX, 256); \
00183 _orxDebug_SetLogFile(zBuffer); \
00184 } while(orxFALSE)
00185
00186
00187 #ifdef __orxGCC__
00188 #define orxASSERT(TEST, ...) \
00189 if(!(TEST)) \
00190 { \
00191 orxDEBUG_PRINT(orxDEBUG_LEVEL_ASSERT, "[Assertion failed] : <" #TEST ">", ##__VA_ARGS__); \
00192 orxBREAK(); \
00193 }
00194 #else
00195 #ifdef __orxMSVC__
00196 #define orxASSERT(TEST, ...) \
00197 if(!(TEST)) \
00198 { \
00199 orxDEBUG_PRINT(orxDEBUG_LEVEL_ASSERT, "[Assertion failed] : <" #TEST ">", __VA_ARGS__); \
00200 orxBREAK(); \
00201 }
00202 #endif
00203 #endif
00204
00205 #else
00206
00207 #define orxDEBUG_PRINT(LEVEL, STRING, ...)
00208
00209 #define orxBREAK()
00210
00211 #define orxDEBUG_SETDEBUGFILE(FILE)
00212 #define orxDEBUG_SETLOGFILE(FILE) _orxDebug_SetLogFile(FILE)
00213 #define orxDEBUG_SETBASEFILENAME(FILE) \
00214 do \
00215 { \
00216 orxCHAR zBuffer[256]; \
00217 strncpy(zBuffer, FILE, 256); \
00218 strncat(zBuffer, orxDEBUG_KZ_DEFAULT_LOG_SUFFIX, 256); \
00219 _orxDebug_SetLogFile(zBuffer); \
00220 } while(orxFALSE)
00221
00222 #define orxASSERT(TEST, ...)
00223
00224 #define orxDEBUG_FLAG_SET(SET, UNSET)
00225 #define orxDEBUG_FLAG_BACKUP()
00226 #define orxDEBUG_FLAG_RESTORE()
00227
00228 #endif
00229
00230
00231
00232
00233
00234
00235
00236 #define orxDEBUG_KS32_BUFFER_MAX_NUMBER 32
00237 #define orxDEBUG_KS32_BUFFER_OUTPUT_SIZE 1024
00238
00239 #define orxDEBUG_KZ_DATE_FORMAT "[%Y-%m-%d %H:%M:%S]"
00240
00241
00242
00243
00244
00245 typedef enum __orxDEBUG_LEVEL_t
00246 {
00247 orxDEBUG_LEVEL_ANIM = 0,
00248 orxDEBUG_LEVEL_CLOCK,
00249 orxDEBUG_LEVEL_DISPLAY,
00250 orxDEBUG_LEVEL_FILE,
00251 orxDEBUG_LEVEL_INPUT,
00252 orxDEBUG_LEVEL_JOYSTICK,
00253 orxDEBUG_LEVEL_KEYBOARD,
00254 orxDEBUG_LEVEL_MEMORY,
00255 orxDEBUG_LEVEL_MOUSE,
00256 orxDEBUG_LEVEL_OBJECT,
00257 orxDEBUG_LEVEL_PARAM,
00258 orxDEBUG_LEVEL_PHYSICS,
00259 orxDEBUG_LEVEL_PLUGIN,
00260 orxDEBUG_LEVEL_PROFILER,
00261 orxDEBUG_LEVEL_RENDER,
00262 orxDEBUG_LEVEL_SCREENSHOT,
00263 orxDEBUG_LEVEL_SOUND,
00264 orxDEBUG_LEVEL_SYSTEM,
00265 orxDEBUG_LEVEL_TIMER,
00267 orxDEBUG_LEVEL_USER,
00269 orxDEBUG_LEVEL_LOG,
00271 orxDEBUG_LEVEL_ASSERT,
00272 orxDEBUG_LEVEL_CRITICAL_ASSERT,
00274 orxDEBUG_LEVEL_NUMBER,
00275
00276 orxDEBUG_LEVEL_MAX_NUMBER = 32,
00277
00278 orxDEBUG_LEVEL_ALL = 0xFFFFFFFE,
00280 orxDEBUG_LEVEL_NONE = orxENUM_NONE
00281
00282 } orxDEBUG_LEVEL;
00283
00284
00285
00286
00287
00288
00292 extern orxDLLAPI orxSTATUS orxFASTCALL _orxDebug_Init();
00293
00295 extern orxDLLAPI void orxFASTCALL _orxDebug_Exit();
00296
00304 extern orxDLLAPI void orxCDECL _orxDebug_Log(orxDEBUG_LEVEL _eLevel, const orxSTRING _zFunction, const orxSTRING _zFile, orxU32 _u32Line, const orxSTRING _zFormat, ...);
00305
00307 extern orxDLLAPI void orxFASTCALL _orxDebug_BackupFlags();
00308
00310 extern orxDLLAPI void orxFASTCALL _orxDebug_RestoreFlags();
00311
00316 extern orxDLLAPI void orxFASTCALL _orxDebug_SetFlags(orxU32 _u32Add, orxU32 _u32Remove);
00317
00319 extern orxDLLAPI void orxFASTCALL _orxDebug_Break();
00320
00324 extern orxDLLAPI void orxFASTCALL _orxDebug_SetDebugFile(const orxSTRING _zFileName);
00325
00329 extern orxDLLAPI void orxFASTCALL _orxDebug_SetLogFile(const orxSTRING _zFileName);
00330
00331 #endif
00332