12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- //---------------------------------------------------------------------------
- #ifndef CommLogFH
- #define CommLogFH
- //---------------------------------------------------------------------------
- #include <windows.h>
- #include <SyncObjs.hpp>
- #include <stdio.h>
- //---------------------------------------------------------------------------
- #define LOG_DISPLAY_FIRST 1
- #define MAX_LOG_BUFFER 2048
- // 로그 종류
- 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...) CommLog->LogWrite(NULL, eLOG_INFO, ##args)
- #define LOGDATA(args...) CommLog->LogWrite(NULL, eLOG_DATA, ##args)
- #define LOGERROR(args...) CommLog->LogWrite(NULL, eLOG_ERROR, ##args)
- #define LOGWARN(args...) CommLog->LogWrite(NULL, eLOG_WARNING, ##args)
- #define LOGDEBUG(args...) CommLog->LogWrite(NULL, eLOG_DEBUG, ##args)
- //---------------------------------------------------------------------------
- #define DBERRORMSG(v,w,x,y) CommLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,true)
- #define DBERRORLOG(v,w,x,y) CommLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,false)
- //---------------------------------------------------------------------------
- class TCommLog
- {
- public:
- TCommLog(String ALogDir, String ALogName, String ALogDay);
- ~TCommLog();
- protected:
- public:
- String FLogDay;
- String FLogFile;
- 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);
- };
- //---------------------------------------------------------------------------
- extern PACKAGE TCommLog *CommLog;
- extern LOG_INFO g_LogCfg;
- //---------------------------------------------------------------------------
- #endif
|