![]() |
OpenNI 1.5.7
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.x Alpha * 00004 * Copyright (C) 2012 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); * 00009 * you may not use this file except in compliance with the License. * 00010 * You may obtain a copy of the License at * 00011 * * 00012 * http://www.apache.org/licenses/LICENSE-2.0 * 00013 * * 00014 * Unless required by applicable law or agreed to in writing, software * 00015 * distributed under the License is distributed on an "AS IS" BASIS, * 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00017 * See the License for the specific language governing permissions and * 00018 * limitations under the License. * 00019 * * 00020 *****************************************************************************/ 00021 #ifndef _XN_LOG_H_ 00022 #define _XN_LOG_H_ 00023 00024 //--------------------------------------------------------------------------- 00025 // Includes 00026 //--------------------------------------------------------------------------- 00027 #include "XnOS.h" 00028 #include "XnLogTypes.h" 00029 #include "XnDump.h" 00030 00031 //--------------------------------------------------------------------------- 00032 // Exported Function Declaration 00033 //--------------------------------------------------------------------------- 00034 00044 XN_C_API XnStatus XN_C_DECL xnLogInitSystem(); 00045 00052 XN_C_API XnStatus XN_C_DECL xnLogInitFromINIFile(const XnChar* csINIFile, const XnChar* csSectionName); 00053 00059 XN_C_API XnStatus XN_C_DECL xnLogInitFromXmlFile(const XnChar* strFileName); 00060 00064 XN_C_API XnStatus XN_C_DECL xnLogClose(); 00065 00066 // @} 00067 00080 XN_C_API XnStatus XN_C_DECL xnLogSetMaskMinSeverity(const XnChar* strMask, XnLogSeverity minSeverity); 00081 00089 XN_C_API XnLogSeverity XN_C_DECL xnLogGetMaskMinSeverity(const XnChar* strMask); 00090 00091 // @} 00092 00105 XN_C_API XnStatus XN_C_DECL xnLogRegisterLogWriter(XnLogWriter* pWriter); 00106 00112 XN_C_API void XN_C_DECL xnLogUnregisterLogWriter(XnLogWriter* pWriter); 00113 00119 XN_C_API XnStatus XN_C_DECL xnLogSetConsoleOutput(XnBool bConsoleOutput); 00120 00126 XN_C_API XnStatus XN_C_DECL xnLogSetFileOutput(XnBool bFileOutput); 00127 00128 #if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM 00129 00133 XN_C_API XnStatus XN_C_DECL xnLogSetAndroidOutput(XnBool bAndroidOutput); 00134 #endif 00135 00136 // @} 00137 00147 XN_C_API XnStatus XN_C_DECL xnLogStartNewFile(); 00148 00154 XN_C_API XnStatus XN_C_DECL xnLogSetLineInfo(XnBool bLineInfo); 00155 00161 XN_C_API XnStatus XN_C_DECL xnLogSetOutputFolder(const XnChar* strOutputFolder); 00162 00169 XN_C_API XnStatus XN_C_DECL xnLogGetFileName(XnChar* strFileName, XnUInt32 nBufferSize); 00170 00171 // @} 00172 00184 XN_C_API XnLogger* XN_C_DECL xnLoggerOpen(const XnChar* strMask); 00185 00198 XN_C_API void XN_C_DECL xnLoggerWrite(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFile, XnUInt32 nLine, const XnChar* strFormat, ...); 00199 00207 XN_C_API void XN_C_DECL xnLoggerWriteNoEntry(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFormat, ...); 00208 00220 XN_C_API void XN_C_DECL xnLoggerWriteBinaryData(XnLogger* pLogger, XnLogSeverity severity, const XnChar* strFile, XnUInt32 nLine, XnUChar* pBinData, XnUInt32 nDataSize, const XnChar* strFormat, ...); 00221 00228 XN_C_API XnBool XN_C_DECL xnLoggerIsEnabled(XnLogger* pLogger, XnLogSeverity severity); 00229 00235 XN_C_API void XN_C_DECL _xnLoggerClose(XnLogger* pLogger); 00236 00242 #define xnLoggerClose(pLogger) \ 00243 { \ 00244 _xnLoggerClose(pLogger); \ 00245 pLogger = NULL; \ 00246 } 00247 00248 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE 00249 00252 #define xnLoggerWriteHelper(pLogger, severity, csFormat, ...) \ 00253 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \ 00254 { \ 00255 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, __VA_ARGS__); \ 00256 } 00257 00261 #define xnLoggerVerbose(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat, __VA_ARGS__) 00262 00265 #define xnLoggerInfo(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, __VA_ARGS__) 00266 00269 #define xnLoggerWarning(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, __VA_ARGS__) 00270 00273 #define xnLoggerError(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, __VA_ARGS__) 00274 00283 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat, ...) \ 00284 { \ 00285 xnLoggerWriteHelper(pLogger, severity, csFormat, __VA_ARGS__); \ 00286 return (nRetVal); \ 00287 } 00288 00296 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat, ...) \ 00297 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat, __VA_ARGS__) 00298 00306 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat, ...) \ 00307 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat, __VA_ARGS__) 00308 00309 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE 00310 #define xnLoggerWriteHelper(pLogger, severity, csFormat, ...) \ 00311 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \ 00312 { \ 00313 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \ 00314 } 00315 00316 #define xnLoggerVerbose(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat,## __VA_ARGS__) 00317 #define xnLoggerInfo(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, ##__VA_ARGS__) 00318 #define xnLoggerWarning(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, ##__VA_ARGS__) 00319 #define xnLoggerError(pLogger, csFormat, ...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, ##__VA_ARGS__) 00320 00321 /* Writes to the log and returns nRetVal */ 00322 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat, ...) \ 00323 { \ 00324 xnLoggerWriteHelper(pLogger, severity, csFormat, ##__VA_ARGS__); \ 00325 return (nRetVal); \ 00326 } 00327 00328 /* Logs a warning and returns nRetVal */ 00329 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat, ...) \ 00330 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat, ##__VA_ARGS__) 00331 00332 /* Logs an error and returns nRetVal */ 00333 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat, ...) \ 00334 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat, ##__VA_ARGS__) 00335 00336 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE 00337 #define xnLoggerWriteHelper(pLogger, severity, csFormat...) \ 00338 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \ 00339 { \ 00340 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat); \ 00341 } 00342 00343 #define xnLoggerVerbose(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat) 00344 #define xnLoggerInfo(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat) 00345 #define xnLoggerWarning(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat) 00346 #define xnLoggerError(pLogger, csFormat...) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat) 00347 00348 /* Writes to the log and returns nRetVal */ 00349 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat...) \ 00350 { \ 00351 xnLoggerWriteHelper(pLogger, severity, csFormat); \ 00352 return (nRetVal); \ 00353 } 00354 00355 /* Logs a warning and returns nRetVal */ 00356 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat...) \ 00357 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat) 00358 00359 /* Logs an error and returns nRetVal */ 00360 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat...) \ 00361 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat) 00362 00363 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS 00364 #define xnLoggerWriteHelper(pLogger, severity, csFormat, arg) \ 00365 if (pLogger != NULL && severity >= pLogger->nMinSeverity) \ 00366 { \ 00367 xnLoggerWrite(pLogger, severity, __FILE__, __LINE__, csFormat, arg); \ 00368 } 00369 00370 #define xnLoggerVerbose(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_VERBOSE, csFormat, arg) 00371 #define xnLoggerInfo(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_INFO, csFormat, arg) 00372 #define xnLoggerWarning(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_WARNING, csFormat, arg) 00373 #define xnLoggerError(pLogger, csFormat, arg) xnLoggerWriteHelper(pLogger, XN_LOG_ERROR, csFormat, arg) 00374 00375 /* Writes to the log and returns nRetVal */ 00376 #define XN_RETURN_WITH_LOG(pLogger, nRetVal, severity, csFormat) \ 00377 { \ 00378 xnLoggerWriteHelper(pLogger, severity, csFormat); \ 00379 return (nRetVal); \ 00380 } 00381 00382 /* Logs a warning and returns nRetVal */ 00383 #define XN_RETURN_WITH_WARNING_LOG(pLogger, nRetVal, csFormat) \ 00384 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_WARNING, csFormat) 00385 00386 /* Logs an error and returns nRetVal */ 00387 #define XN_RETURN_WITH_ERROR_LOG(pLogger, nRetVal, csFormat) \ 00388 XN_RETURN_WITH_LOG(pLogger, nRetVal, XN_LOG_ERROR, csFormat) 00389 00390 #else 00391 #error Xiron Log - Unknown VAARGS type! 00392 #endif 00393 00394 // @} 00395 00413 XN_C_API XnStatus XN_C_DECL xnLogCreateNewFile(const XnChar* strName, XnBool bSessionBased, XnChar* csFullPath, XnUInt32 nPathBufferSize, XN_FILE_HANDLE* phFile); 00414 00415 // @} 00416 00417 #define XN_MASK_RETVAL_CHECKS "RetValChecks" 00418 00419 #if XN_PLATFORM == XN_PLATFORM_ARC 00420 extern "C" XnLogger* XN_LOGGER_RETVAL_CHECKS; 00421 #else 00422 XN_C_API XnLogger* XN_LOGGER_RETVAL_CHECKS; 00423 #endif 00424 00426 #define XN_IS_STATUS_OK_LOG_ERROR(what, nRetVal) \ 00427 if (nRetVal != XN_STATUS_OK) \ 00428 { \ 00429 xnLoggerError(XN_LOGGER_RETVAL_CHECKS, "Failed to " what ": %s", xnGetStatusString(nRetVal)); \ 00430 XN_ASSERT(FALSE); \ 00431 return (nRetVal); \ 00432 } 00433 00434 00435 #ifndef __XN_NO_BC__ 00436 00437 XN_C_API XnStatus XN_API_DEPRECATED("Please use xnLogSetMaskMinSeverity() instead") XN_C_DECL xnLogSetMaskState(const XnChar* csMask, XnBool bEnabled); 00438 XN_C_API XnStatus XN_API_DEPRECATED("Please use xnLogSetMaskMinSeverity() instead") XN_C_DECL xnLogSetSeverityFilter(XnLogSeverity nMinSeverity); 00439 XN_C_API XnBool XN_C_DECL xnLogIsEnabled(const XnChar* csLogMask, XnLogSeverity nSeverity); 00440 XN_C_API void XN_C_DECL xnLogWrite(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, const XnChar* csFormat, ...); 00441 XN_C_API void XN_C_DECL xnLogWriteNoEntry(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFormat, ...); 00442 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, ...); 00443 XN_C_API XnStatus XN_API_DEPRECATED("Use xnLogCreateNewFile() instead") XN_C_DECL xnLogCreateFile(const XnChar* strFileName, XN_FILE_HANDLE* phFile); 00444 XN_C_API XnStatus XN_API_DEPRECATED("Use xnLogCreateNewFile() instead") XN_C_DECL xnLogCreateFileEx(const XnChar* strFileName, XnBool bSessionBased, XN_FILE_HANDLE* phFile); 00445 00446 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE 00447 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00448 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00449 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00450 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00451 00452 /* Writes to the log and returns nRetVal */ 00453 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \ 00454 { \ 00455 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, __VA_ARGS__); \ 00456 return (nRetVal); \ 00457 } 00458 00459 /* Logs a warning and returns nRetVal */ 00460 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00461 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, __VA_ARGS__) 00462 00463 /* Logs a warning and returns nRetVal */ 00464 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00465 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, __VA_ARGS__) 00466 00467 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE 00468 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00469 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00470 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00471 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00472 00473 /* Writes to the log and returns nRetVal */ 00474 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \ 00475 { \ 00476 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \ 00477 return (nRetVal); \ 00478 } 00479 00480 /* Logs a warning and returns nRetVal */ 00481 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00482 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, ##__VA_ARGS__) 00483 00484 /* Logs a warning and returns nRetVal */ 00485 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00486 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, ##__VA_ARGS__) 00487 00488 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE 00489 #define xnLogVerbose(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat) 00490 #define xnLogInfo(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat) 00491 #define xnLogWarning(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat) 00492 #define xnLogError(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat) 00493 00494 /* Writes to the log and returns nRetVal */ 00495 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat...) \ 00496 { \ 00497 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat); \ 00498 return (nRetVal); \ 00499 } 00500 00501 /* Logs a warning and returns nRetVal */ 00502 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat...) \ 00503 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat) 00504 00505 /* Logs a warning and returns nRetVal */ 00506 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat...) \ 00507 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat) 00508 00509 /* If nRetVal is not ok, writes to the log and returns nRetVal */ 00510 #define XN_IS_STATUS_OK_LOG(nRetVal, nSeverity, csLogMask, csFormat...) \ 00511 if (nRetVal != XN_STATUS_OK) \ 00512 { \ 00513 XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat) \ 00514 } 00515 00516 /* If nRetVal is not ok, logs a warning and returns nRetVal */ 00517 #define XN_IS_STATUS_OK_WARNING(nRetVal, csLogMask, csFormat...) \ 00518 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_WARNING, csLogMask, csFormat) 00519 00520 /* If nRetVal is not ok, logs an error and returns nRetVal */ 00521 #define XN_IS_STATUS_OK_ERROR(nRetVal, csLogMask, csFormat...) \ 00522 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_ERROR, csLogMask, csFormat) 00523 00524 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS 00525 #define xnLogVerbose(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, args) 00526 #define xnLogInfo(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, args) 00527 #define xnLogWarning(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, args) 00528 #define xnLogError(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, args) 00529 00530 /* Writes to the log and returns nRetVal */ 00531 #define XN_LOG_RETURN(nRetVal, nSeverity csLogMask, csFormat, args) \ 00532 { \ 00533 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, args); \ 00534 return (nRetVal); \ 00535 } 00536 00537 /* Logs a warning and returns nRetVal */ 00538 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, args) \ 00539 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, args) 00540 00541 /* Logs an error and returns nRetVal */ 00542 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, args) \ 00543 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, args) 00544 00545 #else 00546 #error Xiron Log - Unknown VAARGS type! 00547 #endif 00548 00549 #endif // ifndef __XN_NO_BC__ 00550 00551 #endif //_XN_LOG_H_ 00552