123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #if !defined(__ITSLog_DLL_H__)
- #define __ITSLog_DLL_H__
- #include <vcl.h>
- #include <Classes.hpp>
- #include <math.h>
- #include <map>
- #include <vector>
- #include <list>
- #include <algorithm>
- #include <windows.h>
- #include <SyncObjs.hpp>
- #include <stdio.h>
- /*
- *****************************************************************************
- * 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__ */
|