//--------------------------------------------------------------------------- #ifndef CommLogFH #define CommLogFH //--------------------------------------------------------------------------- #include #include #include //--------------------------------------------------------------------------- #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