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
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
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
00199 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \
00200 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, __VA_ARGS__)
00201
00202
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
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
00220 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, ...) \
00221 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, ##__VA_ARGS__)
00222
00223
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
00234 #define XN_LOG_RETURN(nRetVal, nSeverity, csLogMask, csFormat...) \
00235 { \
00236 xnLogWrite(csLogMask, nSeverity, __FILE__, __LINE__, csFormat); \
00237 return (nRetVal); \
00238 }
00239
00240
00241 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat...) \
00242 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat)
00243
00244
00245 #define XN_LOG_ERROR_RETURN(nRetVal, csLogMask, csFormat...) \
00246 XN_LOG_RETURN(nRetVal, XN_LOG_ERROR, csLogMask, csFormat)
00247
00248
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
00256 #define XN_IS_STATUS_OK_WARNING(nRetVal, csLogMask, csFormat...) \
00257 XN_IS_STATUS_OK_LOG(nRetVal, XN_LOG_WARNING, csLogMask, csFormat)
00258
00259
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
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
00277 #define XN_LOG_WARNING_RETURN(nRetVal, csLogMask, csFormat, args) \
00278 XN_LOG_RETURN(nRetVal, XN_LOG_WARNING, csLogMask, csFormat, args)
00279
00280
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