OpenNI 1.3.2
|
00001 /**************************************************************************** 00002 * * 00003 * OpenNI 1.1 Alpha * 00004 * Copyright (C) 2011 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * OpenNI is free software: you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published * 00010 * by the Free Software Foundation, either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * OpenNI is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with OpenNI. If not, see <http://www.gnu.org/licenses/>. * 00020 * * 00021 ****************************************************************************/ 00022 #ifndef _XN_LOG_H_ 00023 #define _XN_LOG_H_ 00024 00025 //--------------------------------------------------------------------------- 00026 // Includes 00027 //--------------------------------------------------------------------------- 00028 #include "XnOS.h" 00029 #include "XnLogTypes.h" 00030 #include "XnDump.h" 00031 00032 //--------------------------------------------------------------------------- 00033 // Exported Function Declaration 00034 //--------------------------------------------------------------------------- 00035 00039 XN_C_API XnStatus XN_C_DECL xnLogInitSystem(); 00040 00047 XN_C_API XnStatus XN_C_DECL xnLogInitFromINIFile(const XnChar* csINIFile, const XnChar* csSectionName); 00048 00054 XN_C_API XnStatus XN_C_DECL xnLogInitFromXmlFile(const XnChar* strFileName); 00055 00061 XN_C_API XnStatus XN_C_DECL xnLogRegisterLogWriter(const XnLogWriter* pWriter); 00062 00068 XN_C_API void XN_C_DECL xnLogUnregisterLogWriter(const XnLogWriter* pWriter); 00069 00073 XN_C_API XnStatus XN_C_DECL xnLogStartNewFile(); 00074 00078 XN_C_API XnStatus XN_C_DECL xnLogClose(); 00079 00086 XN_C_API XnStatus XN_C_DECL xnLogSetMaskState(const XnChar* csMask, XnBool bEnabled); 00087 00093 XN_C_API XnStatus XN_C_DECL xnLogSetSeverityFilter(XnLogSeverity nMinSeverity); 00094 00100 XN_C_API XnStatus XN_C_DECL xnLogSetConsoleOutput(XnBool bConsoleOutput); 00101 00107 XN_C_API XnStatus XN_C_DECL xnLogSetFileOutput(XnBool bFileOutput); 00108 00114 XN_C_API XnStatus XN_C_DECL xnLogSetLineInfo(XnBool bLineInfo); 00115 00121 XN_C_API XnStatus XN_C_DECL xnLogSetOutputFolder(const XnChar* strOutputFolder); 00122 00129 XN_C_API XnBool XN_C_DECL xnLogIsEnabled(const XnChar* csLogMask, XnLogSeverity nSeverity); 00130 00140 XN_C_API void XN_C_DECL xnLogWrite(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, const XnChar* csFormat, ...); 00141 00151 XN_C_API void XN_C_DECL xnLogWriteNoEntry(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFormat, ...); 00152 00164 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, ...); 00165 00172 XN_C_API XnStatus XN_C_DECL xnLogCreateFile(const XnChar* csFileName, XN_FILE_HANDLE* phFile); 00173 00174 #define XN_MASK_RETVAL_CHECKS "RetValChecks" 00175 00177 #define XN_IS_STATUS_OK_LOG_ERROR(what, nRetVal) \ 00178 if (nRetVal != XN_STATUS_OK) \ 00179 { \ 00180 xnLogError(XN_MASK_RETVAL_CHECKS, "Failed to " what ": %s", xnGetStatusString(nRetVal)); \ 00181 XN_ASSERT(FALSE); \ 00182 return (nRetVal); \ 00183 } 00184 00185 #if XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_WIN32_VAARGS_STYLE 00186 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00187 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00188 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00189 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, __VA_ARGS__) 00190 00191 /* Writes to the log and returns nRetVal */ 00192 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \ 00193 { \ 00194 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, __VA_ARGS__);\ 00195 return (nRetVal); \ 00196 } 00197 00198 /* Logs a warning and returns nRetVal */ 00199 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00200 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, __VA_ARGS__) 00201 00202 /* Logs an error and returns nRetVal */ 00203 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00204 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, __VA_ARGS__) 00205 00206 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_GCC_VAARGS_STYLE 00207 #define xnLogVerbose(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00208 #define xnLogInfo(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00209 #define xnLogWarning(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00210 #define xnLogError(csLogMask, csFormat, ...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, ##__VA_ARGS__) 00211 00212 /* Writes to the log and returns nRetVal */ 00213 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat, ...) \ 00214 { \ 00215 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, ##__VA_ARGS__); \ 00216 return (nRetVal); \ 00217 } 00218 00219 /* Logs a warning and returns nRetVal */ 00220 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00221 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, ##__VA_ARGS__) 00222 00223 /* Logs a warning and returns nRetVal */ 00224 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, ...) \ 00225 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, ##__VA_ARGS__) 00226 00227 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_ARC_VAARGS_STYLE 00228 #define xnLogVerbose(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat) 00229 #define xnLogInfo(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat) 00230 #define xnLogWarning(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat) 00231 #define xnLogError(csLogMask, csFormat...) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat) 00232 00233 /* Writes to the log and returns nRetVal */ 00234 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat...) \ 00235 { \ 00236 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat); \ 00237 return (nRetVal); \ 00238 } 00239 00240 /* Logs a warning and returns nRetVal */ 00241 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat...) \ 00242 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat) 00243 00244 /* Logs a warning and returns nRetVal */ 00245 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat...) \ 00246 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat) 00247 00248 /* If nRetVal is not ok, writes to the log and returns nRetVal */ 00249 #define XN_IS_STATUS_OK_LOG(nRetVal, nSeverity, csLogMask, csFormat...) \ 00250 if (nRetVal != XN_STATUS_OK) \ 00251 { \ 00252 XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat) \ 00253 } 00254 00255 /* If nRetVal is not ok, logs a warning and returns nRetVal */ 00256 #define XN_IS_STATUS_OK_WARNING(nRetVal, csLogMask, csFormat...) \ 00257 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_WARNING, csLogMask, csFormat) 00258 00259 /* If nRetVal is not ok, logs an error and returns nRetVal */ 00260 #define XN_IS_STATUS_OK_ERROR(nRetVal, csLogMask, csFormat...) \ 00261 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_ERROR, csLogMask, csFormat) 00262 00263 #elif XN_PLATFORM_VAARGS_TYPE == XN_PLATFORM_USE_NO_VAARGS 00264 #define xnLogVerbose(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_VERBOSE, __FILE__, __LINE__, csFormat, args) 00265 #define xnLogInfo(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_INFO, __FILE__, __LINE__, csFormat, args) 00266 #define xnLogWarning(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_WARNING, __FILE__, __LINE__, csFormat, args) 00267 #define xnLogError(csLogMask, csFormat, args) xnLogWrite(csLogMask, XN_LOG_ERROR, __FILE__, __LINE__, csFormat, args) 00268 00269 /* Writes to the log and returns nRetVal */ 00270 #define XN_LOG_RETURN(nRetVal, nSeverity csLogMask, csFormat, args) \ 00271 { \ 00272 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat, args); \ 00273 return (nRetVal); \ 00274 } 00275 00276 /* Logs a warning and returns nRetVal */ 00277 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, args) \ 00278 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, args) 00279 00280 /* Logs an error and returns nRetVal */ 00281 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat, args) \ 00282 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat, args) 00283 00284 #else 00285 #error Xiron Log - Unknown VAARGS type! 00286 #endif 00287 00288 #endif //_XN_LOG_H_ 00289