53 #define orxDEBUG_KU32_STATIC_FLAG_NONE 0x00000000 55 #define orxDEBUG_KU32_STATIC_FLAG_TIMESTAMP 0x00000001 56 #define orxDEBUG_KU32_STATIC_FLAG_FULL_TIMESTAMP 0x00000002 57 #define orxDEBUG_KU32_STATIC_FLAG_TYPE 0x00000004 58 #define orxDEBUG_KU32_STATIC_FLAG_TAGGED 0x00000008 60 #define orxDEBUG_KU32_STATIC_FLAG_FILE 0x00000010 61 #define orxDEBUG_KU32_STATIC_FLAG_TERMINAL 0x00000020 62 #define orxDEBUG_KU32_STATIC_FLAG_CONSOLE 0x00000040 63 #define orxDEBUG_KU32_STATIC_FLAG_CALLBACK 0x00000080 65 #define orxDEBUG_KU32_STATIC_MASK_DEFAULT 0x000000F5 67 #define orxDEBUG_KU32_STATIC_MASK_DEBUG 0x000000BD 69 #define orxDEBUG_KU32_STATIC_MASK_USER_ALL 0x0FFFFFFF 74 #define orxDEBUG_KZ_DEFAULT_DEBUG_FILE "orx-debug.log" 75 #define orxDEBUG_KZ_DEFAULT_LOG_FILE "orx.log" 76 #define orxDEBUG_KZ_DEFAULT_LOG_SUFFIX ".log" 77 #define orxDEBUG_KZ_DEFAULT_DEBUG_SUFFIX "-debug.log" 81 typedef enum __orxDEBUG_LEVEL_t
129 #if defined(__orxGCC__) || defined(__orxLLVM__) 131 #define orxLOG(STRING, ...) \ 134 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \ 137 #define orxLOG_TERMINAL(STRING, ...) \ 140 orxU32 u32DebugFlags; \ 141 u32DebugFlags = _orxDebug_GetFlags(); \ 142 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_TERMINAL, \ 143 orxDEBUG_KU32_STATIC_FLAG_FILE \ 144 |orxDEBUG_KU32_STATIC_FLAG_CONSOLE); \ 145 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \ 146 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 149 #define orxLOG_FILE(STRING, ...) \ 152 orxU32 u32DebugFlags; \ 153 u32DebugFlags = _orxDebug_GetFlags(); \ 154 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_FILE, \ 155 orxDEBUG_KU32_STATIC_FLAG_CONSOLE \ 156 |orxDEBUG_KU32_STATIC_FLAG_TERMINAL); \ 157 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \ 158 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 161 #define orxLOG_CONSOLE(STRING, ...) \ 164 orxU32 u32DebugFlags; \ 165 u32DebugFlags = _orxDebug_GetFlags(); \ 166 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_CONSOLE, \ 167 orxDEBUG_KU32_STATIC_FLAG_FILE \ 168 |orxDEBUG_KU32_STATIC_FLAG_TERMINAL); \ 169 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \ 170 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 176 #define orxLOG(STRING, ...) \ 179 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \ 182 #define orxLOG_TERMINAL(STRING, ...) \ 185 orxU32 u32DebugFlags; \ 186 u32DebugFlags = _orxDebug_GetFlags(); \ 187 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_TERMINAL, \ 188 orxDEBUG_KU32_STATIC_FLAG_FILE \ 189 |orxDEBUG_KU32_STATIC_FLAG_CONSOLE); \ 190 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \ 191 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 194 #define orxLOG_FILE(STRING, ...) \ 197 orxU32 u32DebugFlags; \ 198 u32DebugFlags = _orxDebug_GetFlags(); \ 199 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_FILE, \ 200 orxDEBUG_KU32_STATIC_FLAG_CONSOLE \ 201 |orxDEBUG_KU32_STATIC_FLAG_TERMINAL); \ 202 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \ 203 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 206 #define orxLOG_CONSOLE(STRING, ...) \ 209 orxU32 u32DebugFlags; \ 210 u32DebugFlags = _orxDebug_GetFlags(); \ 211 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_CONSOLE, \ 212 orxDEBUG_KU32_STATIC_FLAG_FILE \ 213 |orxDEBUG_KU32_STATIC_FLAG_TERMINAL); \ 214 _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \ 215 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 221 #define orxDEBUG_INIT() \ 224 orxU32 u32DebugFlags; \ 226 u32DebugFlags = _orxDebug_GetFlags(); \ 227 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_MASK_DEBUG, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 228 if(orxSystem_GetVersionNumeric() < __orxVERSION__) \ 230 orxLOG("The version of the runtime library [" orxANSI_KZ_COLOR_FG_GREEN "%s" \ 231 orxANSI_KZ_COLOR_FG_DEFAULT "] is " orxANSI_KZ_COLOR_FG_RED orxANSI_KZ_COLOR_BLINK_ON "older" \ 232 orxANSI_KZ_COLOR_FG_DEFAULT orxANSI_KZ_COLOR_BLINK_OFF " than the version used when compiling this program [" \ 233 orxANSI_KZ_COLOR_FG_GREEN "%s" orxANSI_KZ_COLOR_FG_DEFAULT "]." \ 234 orxANSI_KZ_COLOR_FG_RED orxANSI_KZ_COLOR_BLINK_ON " Problems will likely ensue!", \ 235 orxSystem_GetVersionFullString(), __orxVERSION_FULL_STRING__); \ 237 else if(orxSystem_GetVersionNumeric() > __orxVERSION__) \ 239 orxLOG("The version of the runtime library [" orxANSI_KZ_COLOR_FG_GREEN "%s" \ 240 orxANSI_KZ_COLOR_FG_DEFAULT "] is " orxANSI_KZ_COLOR_FG_YELLOW orxANSI_KZ_COLOR_BLINK_ON "more recent" \ 241 orxANSI_KZ_COLOR_FG_DEFAULT orxANSI_KZ_COLOR_BLINK_OFF " than the version used when compiling this program [" \ 242 orxANSI_KZ_COLOR_FG_GREEN "%s" orxANSI_KZ_COLOR_FG_DEFAULT "]." \ 243 orxANSI_KZ_COLOR_FG_YELLOW orxANSI_KZ_COLOR_BLINK_ON " Problems may arise due to possible incompatibilities!",\ 244 orxSystem_GetVersionFullString(), __orxVERSION_FULL_STRING__); \ 246 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 249 #define orxDEBUG_EXIT() _orxDebug_Exit() 254 #if defined(__orxGCC__) || defined(__orxLLVM__) 255 #define orxDEBUG_PRINT(LEVEL, STRING, ...) \ 258 orxU32 u32DebugFlags; \ 259 u32DebugFlags = _orxDebug_GetFlags(); \ 260 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_MASK_DEBUG, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 261 _orxDebug_Log(LEVEL, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); \ 262 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 266 #define orxDEBUG_PRINT(LEVEL, STRING, ...) \ 269 orxU32 u32DebugFlags; \ 270 u32DebugFlags = _orxDebug_GetFlags(); \ 271 _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_MASK_DEBUG, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 272 _orxDebug_Log(LEVEL, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); \ 273 _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL); \ 280 #define orxDEBUG_ENABLE_LEVEL(LEVEL, ENABLE)_orxDebug_EnableLevel(LEVEL, ENABLE) 281 #define orxDEBUG_IS_LEVEL_ENABLED(LEVEL) _orxDebug_IsLevelEnabled(LEVEL) 283 #define orxDEBUG_SET_FLAGS(SET, UNSET) _orxDebug_SetFlags(SET, UNSET) 284 #define orxDEBUG_GET_FLAGS() _orxDebug_GetFlags() 286 #define orxDEBUG_SET_LOG_CALLBACK(CALLBACK) _orxDebug_SetLogCallback(CALLBACK) 289 #define orxBREAK() _orxDebug_Break() 292 #define orxDEBUG_SETDEBUGFILE(FILE) _orxDebug_SetDebugFile(FILE) 293 #define orxDEBUG_SETLOGFILE(FILE) _orxDebug_SetLogFile(FILE) 294 #define orxDEBUG_SETBASEFILENAME(FILE) \ 297 if((FILE != orxNULL) && (FILE != orxSTRING_EMPTY)) \ 299 orxCHAR zBuffer[512]; \ 300 zBuffer[511] = orxCHAR_NULL; \ 302 strncpy(zBuffer, FILE ? FILE : orxSTRING_EMPTY, 256); \ 303 strncat(zBuffer, orxDEBUG_KZ_DEFAULT_DEBUG_SUFFIX, 255); \ 304 _orxDebug_SetDebugFile(zBuffer); \ 306 strncpy(zBuffer, FILE ? FILE : orxSTRING_EMPTY, 256); \ 307 strncat(zBuffer, orxDEBUG_KZ_DEFAULT_LOG_SUFFIX, 255); \ 308 _orxDebug_SetLogFile(zBuffer); \ 312 _orxDebug_SetDebugFile(FILE); \ 313 _orxDebug_SetLogFile(FILE); \ 318 #if defined(__orxGCC__) || defined(__orxLLVM__) 319 #define orxASSERT(TEST, ...) \ 322 orxDEBUG_PRINT(orxDEBUG_LEVEL_ASSERT, orxANSI_KZ_COLOR_BG_RED orxANSI_KZ_COLOR_FG_WHITE orxANSI_KZ_COLOR_BLINK_ON "FAILED ASSERTION [" #TEST "]", ##__VA_ARGS__); \ 327 #define orxASSERT(TEST, ...) \ 330 orxDEBUG_PRINT(orxDEBUG_LEVEL_ASSERT, orxANSI_KZ_COLOR_BG_RED orxANSI_KZ_COLOR_FG_WHITE orxANSI_KZ_COLOR_BLINK_ON "FAILED ASSERTION [" #TEST "]", __VA_ARGS__); \ 338 #define orxDEBUG_PRINT(LEVEL, STRING, ...) 340 #define orxDEBUG_ENABLE_LEVEL(LEVEL, ENABLE)_orxDebug_EnableLevel(LEVEL, ENABLE) 341 #define orxDEBUG_IS_LEVEL_ENABLED(LEVEL) _orxDebug_IsLevelEnabled(LEVEL) 343 #define orxDEBUG_SET_FLAGS(SET, UNSET) _orxDebug_SetFlags(SET, UNSET) 344 #define orxDEBUG_GET_FLAGS() _orxDebug_GetFlags() 346 #define orxDEBUG_SET_LOG_CALLBACK(CALLBACK) _orxDebug_SetLogCallback(CALLBACK) 352 #define orxDEBUG_SETDEBUGFILE(FILE) 353 #define orxDEBUG_SETLOGFILE(FILE) _orxDebug_SetLogFile(FILE) 354 #define orxDEBUG_SETBASEFILENAME(FILE) \ 357 if((FILE != orxNULL) && (FILE != orxSTRING_EMPTY)) \ 359 orxCHAR zBuffer[512]; \ 360 zBuffer[511] = orxCHAR_NULL; \ 362 strncpy(zBuffer, FILE ? FILE : orxSTRING_EMPTY, 256); \ 363 strncat(zBuffer, orxDEBUG_KZ_DEFAULT_LOG_SUFFIX, 255); \ 364 _orxDebug_SetLogFile(zBuffer); \ 368 _orxDebug_SetLogFile(FILE); \ 372 #define orxASSERT(TEST, ...) 382 #define orxDEBUG_KS32_BUFFER_OUTPUT_SIZE 2048 384 #define orxDEBUG_KZ_DATE_FORMAT orxANSI_KZ_COLOR_FG_CYAN "[%H:%M:%S]" orxANSI_KZ_COLOR_RESET 385 #define orxDEBUG_KZ_DATE_FULL_FORMAT orxANSI_KZ_COLOR_FG_CYAN "[%Y-%m-%d %H:%M:%S]" orxANSI_KZ_COLOR_RESET 387 #define orxDEBUG_KZ_TYPE_LOG_FORMAT orxANSI_KZ_COLOR_FG_GREEN "[%s]" orxANSI_KZ_COLOR_RESET 388 #define orxDEBUG_KZ_TYPE_WARNING_FORMAT orxANSI_KZ_COLOR_FG_YELLOW "[%s]" orxANSI_KZ_COLOR_RESET 389 #define orxDEBUG_KZ_TYPE_ERROR_FORMAT orxANSI_KZ_COLOR_FG_RED "[%s]" orxANSI_KZ_COLOR_RESET 391 #define orxDEBUG_KZ_FILE_FORMAT orxANSI_KZ_COLOR_FG_MAGENTA "[%s:%s(%u)]" orxANSI_KZ_COLOR_RESET
orxDLLAPI void orxFASTCALL _orxDebug_SetDebugFile(const orxSTRING _zFileName)
orxSTATUS(orxFASTCALL * orxDEBUG_CALLBACK_FUNCTION)(orxDEBUG_LEVEL _eLevel, const orxSTRING _zFunction, const orxSTRING _zFile, orxU32 _u32Line, const orxSTRING _zLog)
orxDLLAPI void orxFASTCALL _orxDebug_EnableLevel(orxDEBUG_LEVEL _eLevel, orxBOOL _bEnable)
orxDLLAPI void orxFASTCALL _orxDebug_SetLogCallback(const orxDEBUG_CALLBACK_FUNCTION _pfnLogCallback)
orxDLLAPI void orxFASTCALL _orxDebug_SetLogFile(const orxSTRING _zFileName)
orxDLLAPI void orxCDECL _orxDebug_Log(orxDEBUG_LEVEL _eLevel, const orxSTRING _zFunction, const orxSTRING _zFile, orxU32 _u32Line, const orxSTRING _zFormat,...)
orxDLLAPI void orxFASTCALL _orxDebug_Break()
orxDLLAPI orxBOOL orxFASTCALL _orxDebug_IsLevelEnabled(orxDEBUG_LEVEL _eLevel)
orxDLLAPI void orxFASTCALL _orxDebug_Exit()
orxDLLAPI orxSTATUS orxFASTCALL _orxDebug_Init()
orxDLLAPI orxU32 orxFASTCALL _orxDebug_GetFlags()
orxDLLAPI void orxFASTCALL _orxDebug_SetFlags(orxU32 _u32Add, orxU32 _u32Remove)