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(const XnLogWriter* pWriter);
00107
00113 XN_C_API void XN_C_DECL xnLogUnregisterLogWriter(const 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
00156
00157
00169 XN_C_API XnLogger* XN_C_DECL xnLoggerOpen(const XnChar* strMask);
00170
00183 XN_C_API void XN_C_DECL xnLoggerWrite(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFile, XnUInt32 nLine, const XnChar* strFormat, ...);
00184
00192 XN_C_API void XN_C_DECL xnLoggerWriteNoEntry(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFormat, ...);
00193
00205 XN_C_API void XN_C_DECL xnLoggerWriteBinaryData(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFile, XnUInt32 nLine, XnUChar* pBinData, XnUInt32 nDataSize, const XnChar* strFormat, ...);
00206
00213 XN_C_API XnBool XN_C_DECL xnLoggerIsEnabled(XnLogger* pLogger, XnLogSeverity severity);
00214
00220 XN_C_API void XN_C_DECL _xnLoggerClose(XnLogger* pLogger);
00221
00227 #define xnLoggerClose(pLogger) \
00228 { \
00229 _xnLoggerClose(pLogger); \
00230 pLogger = NULL; \
00231 }
00232
00233 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE
00234
00237 #define xnLoggerWriteHelper(pLogger, severity, csFormat, ...) \
00238 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00239 { \
00240 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, __VA_ARGS__); \
00241 }
00242
00246 #define xnLoggerVerbose(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat, __VA_ARGS__)
00247
00250 #define xnLoggerInfo(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, __VA_ARGS__)
00251
00254 #define xnLoggerWarning(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, __VA_ARGS__)
00255
00258 #define xnLoggerError(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, __VA_ARGS__)
00259
00268 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat, ...) \
00269 { \
00270 xnLoggerWriteHelper(pLogger, severity, csFormat, __VA_ARGS__); \
00271 return (nRetVal); \
00272 }
00273
00281 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat, ...) \
00282 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat, __VA_ARGS__)
00283
00291 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat, ...) \
00292 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat, __VA_ARGS__)
00293
00294 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE
00295 #define xnLoggerWriteHelper(pLogger, severity, csFormat, ...) \
00296 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00297 { \
00298 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \
00299 }
00300
00301 #define xnLoggerVerbose(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat,## __VA_ARGS__)
00302 #define xnLoggerInfo(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, ##__VA_ARGS__)
00303 #define xnLoggerWarning(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, ##__VA_ARGS__)
00304 #define xnLoggerError(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, ##__VA_ARGS__)
00305
00306
00307 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat, ...) \
00308 { \
00309 xnLoggerWriteHelper(pLogger, severity, csFormat, ##__VA_ARGS__); \
00310 return (nRetVal); \
00311 }
00312
00313
00314 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat, ...) \
00315 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat, ##__VA_ARGS__)
00316
00317
00318 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat, ...) \
00319 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat, ##__VA_ARGS__)
00320
00321 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE
00322 #define xnLoggerWriteHelper(pLogger, severity, csFormat...) \
00323 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00324 { \
00325 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat); \
00326 }
00327
00328 #define xnLoggerVerbose(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat)
00329 #define xnLoggerInfo(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat)
00330 #define xnLoggerWarning(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat)
00331 #define xnLoggerError(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat)
00332
00333
00334 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat...) \
00335 { \
00336 xnLoggerWriteHelper(pLogger, severity, csFormat); \
00337 return (nRetVal); \
00338 }
00339
00340
00341 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat...) \
00342 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat)
00343
00344
00345 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat...) \
00346 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat)
00347
00348 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS
00349 #define xnLoggerWriteHelper(pLogger, severity, csFormat, arg) \
00350 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \
00351 { \
00352 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, arg); \
00353 }
00354
00355 #define xnLoggerVerbose(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat, arg)
00356 #define xnLoggerInfo(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, arg)
00357 #define xnLoggerWarning(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, arg)
00358 #define xnLoggerError(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, arg)
00359
00360
00361 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat) \
00362 { \
00363 xnLoggerWriteHelper(pLogger, severity, csFormat); \
00364 return (nRetVal); \
00365 }
00366
00367
00368 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat) \
00369 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat)
00370
00371
00372 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat) \
00373 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat)
00374
00375 #else
00376 #error Xiron Log - Unknown VAARGS type!
00377 #endif
00378
00379
00380
00393 XN_C_API XnStatus XN_C_DECL xnLogCreateFile(const XnChar* strFileName, XN_FILE_HANDLE* phFile);
00394
00404 XN_C_API XnStatus XN_C_DECL xnLogCreateFileEx(const XnChar* strFileName, XnBool bSessionBased, XN_FILE_HANDLE* phFile);
00405
00406
00407
00408 #define XN_MASK_RETVAL_CHECKS "RetValChecks"
00409
00410 #if XN_PLATFORM == XN_PLATFORM_ARC
00411 extern "C" XnLogger* XN_LOGGER_RETVAL_CHECKS;
00412 #else
00413 XN_C_API XnLogger* XN_LOGGER_RETVAL_CHECKS;
00414 #endif
00415
00417 #define XN_IS_STATUS_OK_LOG_ERROR(what, nRetVal) \
00418 if (nRetVal != XN_STATUS_OK) \
00419 { \
00420 xnLoggerError(XN_LOGGER_RETVAL_CHECKS, "Failed to " what ": %s", xnGetStatusString(nRetVal)); \
00421 XN_ASSERT(FALSE); \
00422 return (nRetVal); \
00423 }
00424
00425
00426 #ifndef __XN_NO_BC__
00427
00428 XN_C_API XnStatus XN_API_DEPRECATED("Please use xnLogSetMaskMinSeverity() instead") XN_C_DECL xnLogSetMaskState(const XnChar* csMask, XnBool bEnabled);
00429 XN_C_API XnStatus XN_API_DEPRECATED("Please use xnLogSetMaskMinSeverity() instead") XN_C_DECL xnLogSetSeverityFilter(XnLogSeverity nMinSeverity);
00430 XN_C_API XnBool XN_C_DECL xnLogIsEnabled(const XnChar* csLogMask, XnLogSeverity nSeverity);
00431 XN_C_API void XN_C_DECL xnLogWrite(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, const XnChar* csFormat, ...);
00432 XN_C_API void XN_C_DECL xnLogWriteNoEntry(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFormat, ...);
00433 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, ...);
00434
00435 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE
00436 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00437 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00438 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00439 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, __VA_ARGS__)
00440
00441
00442 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \
00443 { \
00444 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, __VA_ARGS__); \
00445 return (nRetVal); \
00446 }
00447
00448
00449 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \
00450 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, __VA_ARGS__)
00451
00452
00453 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \
00454 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, __VA_ARGS__)
00455
00456 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE
00457 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00458 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00459 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00460 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, ##__VA_ARGS__)
00461
00462
00463 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \
00464 { \
00465 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \
00466 return (nRetVal); \
00467 }
00468
00469
00470 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \
00471 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, ##__VA_ARGS__)
00472
00473
00474 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \
00475 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, ##__VA_ARGS__)
00476
00477 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE
00478 #define xnLogVerbose(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat)
00479 #define xnLogInfo(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat)
00480 #define xnLogWarning(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat)
00481 #define xnLogError(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat)
00482
00483
00484 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat...) \
00485 { \
00486 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat); \
00487 return (nRetVal); \
00488 }
00489
00490
00491 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat...) \
00492 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat)
00493
00494
00495 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat...) \
00496 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat)
00497
00498
00499 #define XN_IS_STATUS_OK_LOG(nRetVal, nSeverity, csLogMask, csFormat...) \
00500 if (nRetVal != XN_STATUS_OK) \
00501 { \
00502 XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat) \
00503 }
00504
00505
00506 #define XN_IS_STATUS_OK_WARNING(nRetVal, csLogMask, csFormat...) \
00507 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_WARNING, csLogMask, csFormat)
00508
00509
00510 #define XN_IS_STATUS_OK_ERROR(nRetVal, csLogMask, csFormat...) \
00511 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_ERROR, csLogMask, csFormat)
00512
00513 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS
00514 #define xnLogVerbose(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, args)
00515 #define xnLogInfo(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, args)
00516 #define xnLogWarning(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, args)
00517 #define xnLogError(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, args)
00518
00519
00520 #define XN_LOG_RETURN(nRetVal, nSeverity csLogMask, csFormat, args) \
00521 { \
00522 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, args); \
00523 return (nRetVal); \
00524 }
00525
00526
00527 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, args) \
00528 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, args)
00529
00530
00531 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, args) \
00532 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, args)
00533
00534 #else
00535 #error Xiron Log - Unknown VAARGS type!
00536 #endif
00537
00538 #endif // ifndef __XN_NO_BC__
00539
00540 #endif //_XN_LOG_H_
00541