# Logger.h

    00001 //***************************************************************************************
    00002 //
    00003 // File supervisor: Crosswalk team
    00004 //
    00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.
    00006 // Use of this software is subject to the terms of the Autodesk license agreement
    00007 // provided at the time of installation or download, or which otherwise accompanies
    00008 // this software in either electronic or hard copy form.
    00009 //
    00010 //***************************************************************************************
    00011
    00012 #ifndef __LOGGER_H__
    00013 #define __LOGGER_H__
    00014
    00015 #include <SIBCUtil.h>
    00016
    00018 // Forward declaration
    00020 class CSLLogger;
    00022
    00025
    00030 typedef SI_Bool (*SLLoggerCallBack)( CSLLogger* in_pLogger, SI_Int in_nErrorType,  SI_Void* in_pData);
    00032
    00034 // default CSLLogger callbacks
    00036 XSIEXPORT SI_Bool StdOnInit( CSLLogger *in_pLogger, SI_Int, SI_Void* in_pData );            // writes "Start" to stdout
    00037 XSIEXPORT SI_Bool StdOnFatal( CSLLogger *in_pLogger, SI_Int, SI_Void* in_pData );       // writes "Fatal Error: " in_pData to stderr
    00038 XSIEXPORT SI_Bool StdOnError( CSLLogger *in_pLogger, SI_Int, SI_Void* in_pData );       // writes "Error: " in_pData to stderr
    00039 XSIEXPORT SI_Bool StdOnWarning( CSLLogger *in_pLogger, SI_Int, SI_Void* in_pData );     // writes "Warning: " in_pData to stderr
    00040 XSIEXPORT SI_Bool StdOnVerbose( CSLLogger *in_pLogger, SI_Int, SI_Void* in_pData );     // writes "Info: " in_pData to stdout
    00041 XSIEXPORT SI_Bool StdOnTerm( CSLLogger *in_pLogger, SI_Int, SI_Void* in_pData );            // writes "End" to stdout
    00043
    00046 class XSIEXPORT CSLLogger
    00047 {
    00048 public:
    00049
    00051
    00060     CSLLogger
    00061     (
    00062         SLLoggerCallBack OnInitFunc = StdOnInit,
    00063         SLLoggerCallBack OnFatalFunc = StdOnFatal,
    00064         SLLoggerCallBack OnErrorFunc = StdOnError,
    00065         SLLoggerCallBack OnWarningFunc = StdOnWarning,
    00066         SLLoggerCallBack OnVerboseFunc = StdOnVerbose,
    00067         SLLoggerCallBack OnTermFunc = StdOnTerm,
    00068         SI_Void* in_pUserData = 0
    00069     );
    00070
    00072     enum ELogType
    00073     {
    00074         SI_LOG_INIT = 0,
    00075         SI_LOG_FATAL,
    00076         SI_LOG_ERROR,
    00077         SI_LOG_WARNING,
    00078         SI_LOG_VERBOSE,
    00079         SI_LOG_TERM
    00080     };
    00081
    00083
    00088     SI_Bool Log( ELogType in_Type, SI_Void* in_pData );
    00089
    00091     SI_Void* GetData();
    00092
    00094
    00098     SI_Void* SetData( SI_Void* in_pData );
    00099
    00101
    00106     SLLoggerCallBack SetCallBack( ELogType in_Callback, SLLoggerCallBack in_NewCallback );
    00107
    00109
    00113     SLLoggerCallBack GetCallBack( ELogType in_Callback );
    00114
    00115
    00116 private:
    00117     SI_Void* m_pData;   // pointer to user-defined data
    00118
    00119     SLLoggerCallBack m_pCallBacks[SI_LOG_TERM+1];
    00120 };
    00122
    00123 #endif //__LOGGER_H__