00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _XN_LOG_H_
00023 #define _XN_LOG_H_
00024
00025
00026
00027
00028 #include "XnOS.h"
00029 #include "XnLogTypes.h"
00030 #include "XnDump.h"
00031
00032
00033
00034
00035
00045 XN_C_API XnStatus XN_C_DECL xnLogInitSystem();
00046
00053 XN_C_API XnStatus XN_C_DECL xnLogInitFromINIFile(const XnChar* csINIFile, const XnChar* csSectionName);
00054
00060 XN_C_API XnStatus XN_C_DECL xnLogInitFromXmlFile(const XnChar* strFileName);
00061
00065 XN_C_API XnStatus XN_C_DECL xnLogClose();
00066
00067
00068
00081 XN_C_API XnStatus XN_C_DECL xnLogSetMaskMinSeverity(const XnChar* strMask, XnLogSeverity minSeverity);
00082
00090 XN_C_API XnLogSeverity XN_C_DECL xnLogGetMaskMinSeverity(const XnChar* strMask);
00091
00092
00093
00106 XN_C_API XnStatus XN_C_DECL xnLogRegisterLogWriter(XnLogWriter* pWriter);
00107
00113 XN_C_API void XN_C_DECL xnLogUnregisterLogWriter(XnLogWriter* pWriter);
00114
00120 XN_C_API XnStatus XN_C_DECL xnLogSetConsoleOutput(XnBool bConsoleOutput);
00121
00127 XN_C_API XnStatus XN_C_DECL xnLogSetFileOutput(XnBool bFileOutput);
00128
00129
00130
00140 XN_C_API XnStatus XN_C_DECL xnLogStartNewFile();
00141
00147 XN_C_API XnStatus XN_C_DECL xnLogSetLineInfo(XnBool bLineInfo);
00148
00154 XN_C_API XnStatus XN_C_DECL xnLogSetOutputFolder(const XnChar* strOutputFolder);
00155
00162 XN_C_API XnStatus XN_C_DECL xnLogGetFileName(XnChar* strFileName, XnUInt32 nBufferSize);
00163
00164
00165
00177 XN_C_API XnLogger* XN_C_DECL xnLoggerOpen(const XnChar* strMask);
00178
00191 XN_C_API void XN_C_DECL xnLoggerWrite(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFile, XnUInt32 nLine, const XnChar* strFormat, ...);
00192
00200 XN_C_API void XN_C_DECL xnLoggerWriteNoEntry(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFormat, ...);
00201
00213 XN_C_API void XN_C_DECL xnLoggerWriteBinaryData(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFile, XnUInt32 nLine, XnUChar* pBinData, XnUInt32 nDataSize, const XnChar* strFormat, ...);
00214
00221 XN_C_API XnBool XN_C_DECL xnLoggerIsEnabled(XnLogger* pLogger, XnLogSeverity severity);
00222
00228 XN_C_API void XN_C_DECL _xnLoggerClose(XnLogger* pLogger);
00229
00235 #define xnLoggerClose(pLogger) \
00236 { \
00237 _xnLoggerClose(pLogger); \
00238 pLogger = NULL; \
00239 }
00240
00241 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE
00242
00245 #define xnLoggerWriteHelper(pLogger, severity, csFormat, ...) \
00246 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00247 { \
00248 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, __VA_ARGS__); \
00249 }
00250
00254 #define xnLoggerVerbose(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat, __VA_ARGS__)
00255
00258 #define xnLoggerInfo(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, __VA_ARGS__)
00259
00262 #define xnLoggerWarning(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, __VA_ARGS__)
00263
00266 #define xnLoggerError(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, __VA_ARGS__)
00267
00276 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat, ...) \
00277 { \
00278 xnLoggerWriteHelper(pLogger, severity, csFormat, __VA_ARGS__); \
00279 return (nRetVal); \
00280 }
00281
00289 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat, ...) \
00290 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat, __VA_ARGS__)
00291
00299 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat, ...) \
00300 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat, __VA_ARGS__)
00301
00302 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE
00303 #define xnLoggerWriteHelper(pLogger, severity, csFormat, ...) \
00304 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00305 { \
00306 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \
00307 }
00308
00309 #define xnLoggerVerbose(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat,## __VA_ARGS__)
00310 #define xnLoggerInfo(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, ##__VA_ARGS__)
00311 #define xnLoggerWarning(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, ##__VA_ARGS__)
00312 #define xnLoggerError(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, ##__VA_ARGS__)
00313
00314
00315 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat, ...) \
00316 { \
00317 xnLoggerWriteHelper(pLogger, severity, csFormat, ##__VA_ARGS__); \
00318 return (nRetVal); \
00319 }
00320
00321
00322 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat, ...) \
00323 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat, ##__VA_ARGS__)
00324
00325
00326 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat, ...) \
00327 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat, ##__VA_ARGS__)
00328
00329 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE
00330 #define xnLoggerWriteHelper(pLogger, severity, csFormat...) \
00331 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00332 { \
00333 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat); \
00334 }
00335
00336 #define xnLoggerVerbose(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat)
00337 #define xnLoggerInfo(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat)
00338 #define xnLoggerWarning(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat)
00339 #define xnLoggerError(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat)
00340
00341
00342 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat...) \
00343 { \
00344 xnLoggerWriteHelper(pLogger, severity, csFormat); \
00345 return (nRetVal); \
00346 }
00347
00348
00349 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat...) \
00350 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat)
00351
00352
00353 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat...) \
00354 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat)
00355
00356 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS
00357 #define xnLoggerWriteHelper(pLogger, severity, csFormat, arg) \
00358 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00359 { \
00360 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, arg); \
00361 }
00362
00363 #define xnLoggerVerbose(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat, arg)
00364 #define xnLoggerInfo(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, arg)
00365 #define xnLoggerWarning(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, arg)
00366 #define xnLoggerError(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, arg)
00367
00368
00369 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat) \
00370 { \
00371 xnLoggerWriteHelper(pLogger, severity, csFormat); \
00372 return (nRetVal); \
00373 }
00374
00375
00376 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat) \
00377 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat)
00378
00379
00380 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat) \
00381 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat)
00382
00383 #else
00384 #error Xiron Log - Unknown VAARGS type!
00385 #endif
00386
00387
00388
00406 XN_C_API XnStatus XN_C_DECL xnLogCreateNewFile(const XnChar* strName, XnBool bSessionBased, XnChar* csFullPath, XnUInt32 nPathBufferSize, XN_FILE_HANDLE* phFile);
00407
00408
00409
00410 #define XN_MASK_RETVAL_CHECKS "RetValChecks"
00411
00412 #if XN_PLATFORM == XN_PLATFORM_ARC
00413 extern "C" XnLogger* XN_LOGGER_RETVAL_CHECKS;
00414 #else
00415 XN_C_API XnLogger* XN_LOGGER_RETVAL_CHECKS;
00416 #endif
00417
00419 #define XN_IS_STATUS_OK_LOG_ERROR(what, nRetVal) \
00420 if (nRetVal != XN_STATUS_OK) \
00421 { \
00422 xnLoggerError(XN_LOGGER_RETVAL_CHECKS, "Failed to " what ": %s", xnGetStatusString(nRetVal)); \
00423 XN_ASSERT(FALSE); \
00424 return (nRetVal); \
00425 }
00426
00427
00428 #ifndef __XN_NO_BC__
00429
00430 XN_C_API XnStatus XN_API_DEPRECATED("Please use xnLogSetMaskMinSeverity() instead") XN_C_DECL xnLogSetMaskState(const XnChar* csMask, XnBool bEnabled);
00431 XN_C_API XnStatus XN_API_DEPRECATED("Please use xnLogSetMaskMinSeverity() instead") XN_C_DECL xnLogSetSeverityFilter(XnLogSeverity nMinSeverity);
00432 XN_C_API XnBool XN_C_DECL xnLogIsEnabled(const XnChar* csLogMask, XnLogSeverity nSeverity);
00433 XN_C_API void XN_C_DECL xnLogWrite(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, const XnChar* csFormat, ...);
00434 XN_C_API void XN_C_DECL xnLogWriteNoEntry(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFormat, ...);
00435 XN_C_API void XN_C_DECL xnLogWriteBinaryData(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, XnUChar* pBinData, XnUInt32 nDataSize, const XnChar* csFormat, ...);
00436 XN_C_API XnStatus XN_API_DEPRECATED("Use xnLogCreateNewFile() instead") XN_C_DECL xnLogCreateFile(const XnChar* strFileName, XN_FILE_HANDLE* phFile);
00437 XN_C_API XnStatus XN_API_DEPRECATED("Use xnLogCreateNewFile() instead") XN_C_DECL xnLogCreateFileEx(const XnChar* strFileName, XnBool bSessionBased, XN_FILE_HANDLE* phFile);
00438
00439 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE
00440 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00441 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00442 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00443 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00444
00445
00446 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \
00447 { \
00448 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, __VA_ARGS__); \
00449 return (nRetVal); \
00450 }
00451
00452
00453 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \
00454 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, __VA_ARGS__)
00455
00456
00457 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \
00458 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, __VA_ARGS__)
00459
00460 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE
00461 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00462 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00463 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00464 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00465
00466
00467 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \
00468 { \
00469 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \
00470 return (nRetVal); \
00471 }
00472
00473
00474 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \
00475 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, ##__VA_ARGS__)
00476
00477
00478 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \
00479 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, ##__VA_ARGS__)
00480
00481 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE
00482 #define xnLogVerbose(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat)
00483 #define xnLogInfo(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat)
00484 #define xnLogWarning(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat)
00485 #define xnLogError(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat)
00486
00487
00488 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat...) \
00489 { \
00490 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat); \
00491 return (nRetVal); \
00492 }
00493
00494
00495 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat...) \
00496 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat)
00497
00498
00499 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat...) \
00500 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat)
00501
00502
00503 #define XN_IS_STATUS_OK_LOG(nRetVal, nSeverity, csLogMask, csFormat...) \
00504 if (nRetVal != XN_STATUS_OK) \
00505 { \
00506 XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat) \
00507 }
00508
00509
00510 #define XN_IS_STATUS_OK_WARNING(nRetVal, csLogMask, csFormat...) \
00511 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_WARNING, csLogMask, csFormat)
00512
00513
00514 #define XN_IS_STATUS_OK_ERROR(nRetVal, csLogMask, csFormat...) \
00515 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_ERROR, csLogMask, csFormat)
00516
00517 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS
00518 #define xnLogVerbose(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, args)
00519 #define xnLogInfo(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, args)
00520 #define xnLogWarning(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, args)
00521 #define xnLogError(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, args)
00522
00523
00524 #define XN_LOG_RETURN(nRetVal, nSeverity csLogMask, csFormat, args) \
00525 { \
00526 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, args); \
00527 return (nRetVal); \
00528 }
00529
00530
00531 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, args) \
00532 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, args)
00533
00534
00535 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, args) \
00536 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, args)
00537
00538 #else
00539 #error Xiron Log - Unknown VAARGS type!
00540 #endif
00541
00542 #endif // ifndef __XN_NO_BC__
00543
00544 #endif //_XN_LOG_H_
00545