#if !defined(__ITSLog_DLL_H__) #define __ITSLog_DLL_H__ #include #include #include #include #include #include #include #include #include #include /* ***************************************************************************** * DLL Import/Export ***************************************************************************** */ #ifdef __ITSLog_DLL_EXPORT__ #define ITSLog_LIB __declspec(dllexport) #else #define ITSLog_LIB __declspec(dllimport) //#pragma comment(lib, "ITSLog.lib") /* µ¿ÀûÀ¸·Î dll ·ÎµùÇÒ¶§ »ç¿ëÇÑ´Ù. */ #endif /* ***************************************************************************** * Defines ***************************************************************************** */ #define MAX_LOG_BUFFER 4096 typedef enum eEN_LOG_KIND { eLOG_NONE = 0x00, /* ¾øÀ½ */ eLOG_INFO = 0x01, /* Á¤º¸ */ eLOG_DATA = 0x02, /* µ¥ÀÌÅÍ */ eLOG_ERROR = 0x04, /* ¿¡·¯ */ eLOG_WARNING = 0x08, /* °æ°í */ eLOG_DEBUG = 0x10, /* µð¹ö±× */ eLOG_DETAIL = 0x1F /* »ó¼¼ */ } EN_LOG_KIND; typedef struct tagLogInfo { bool Info; bool Data; bool Error; bool Warning; bool Debug; bool Detail; public: tagLogInfo() { Info = true; Data = false; Error = true; Warning = true; Debug = false; Detail = false; } } LOG_INFO; typedef struct tagLogMessage { int Kind; /* message kind */ int Len; /* message len */ TDateTime Tm; /* message create time */ char Data[MAX_LOG_BUFFER]; /* message data */ } LOG_MESSAGE; //--------------------------------------------------------------------------- #define LOGINFO(args...) ITSLog->LogWrite(NULL, eLOG_INFO, ##args) #define LOGDATA(args...) ITSLog->LogWrite(NULL, eLOG_DATA, ##args) #define LOGERROR(args...) ITSLog->LogWrite(NULL, eLOG_ERROR, ##args) #define LOGWARN(args...) ITSLog->LogWrite(NULL, eLOG_WARNING, ##args) #define LOGDEBUG(args...) ITSLog->LogWrite(NULL, eLOG_DEBUG, ##args) //--------------------------------------------------------------------------- #define DBERRORMSG(v,w,x,y) ITSLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,true) #define DBERRORLOG(v,w,x,y) ITSLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,false) /* * ITS Log class */ class ITSLog_LIB __stdcall TITSLog { private: CRITICAL_SECTION CS; public: TITSLog(String ALogDir, String ALogName, String ALogDay, bool ABackup=false); ~TITSLog(); public: LOG_INFO FLogCfg; String FLogDay; String FErrLogDay; String FLogFile; public: void SendLogMessage(int AKind, char *AFmt, ...); FILE *OpenLogFile(AnsiString AFileExt=".log"); int LogData(char *ASndRcv, const unsigned char *AData, int ALen, FILE *Afp=NULL); int LogWrite(FILE *Afp, int ALogKind, char *AFmt, ...); int LogDbError(String ATitle, String AClass, String AError, String ASql, String AFile, String AFunc, int ALine, bool AShowMsg=true); int LogDbInfo(String ATitle, String ASql); }; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- /* ***************************************************************************** * Function Prototypes ***************************************************************************** */ extern "C" { ITSLog_LIB TITSLog* __stdcall ITSLog_Initialize(String ALogDir, String ALogName, String ALogDay); ITSLog_LIB int __stdcall ITSLog_SetConfig(LOG_INFO &ALogCfg); ITSLog_LIB int __stdcall ITSLog_Term(); } /* extern "C" */ #endif /* __ITSLog_DLL_H__ */