You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.7 KiB
C++

#pragma once
#include "Module.h"
#include "GlobalDefine.h"
#include "EnumPropertieType.h"
//输出日志的类型
enum LOG_TYPE
{
_LOG_NORMAL=0,//正常
_LOG_ERROR,//错误
_LOG_FUNC,//函数
};
class COutputWnd;
class CLog
{
friend class CLogMgr;
public:
CLog(void)
{
bCmdLog = false;
bDebugLog = false;
}
void AddCmdLog(){bCmdLog = true;};
void AddDebugLog(){bDebugLog = true;};
public:
CString str;
private:
bool bCmdLog;
bool bDebugLog;
};
//负责管理程序日志log 的输出
class CLogMgr:public CModule
{
public:
CLogMgr(void);
~CLogMgr(void);
virtual void OnAppInitialize();
virtual CMFCPropertyGridProperty *CreatGridProperty();
virtual MODULE GetModuleType(){return _LOG_PROP;};
public:
void WriteLog(CLog &Log);
ofstream *GetResultOfstream(){return &m_ResultFile;};//调试用
void WriteCmd(CString Cmd,CString val1,CString val2);
void WriteDebugLog(CString Str,LOG_TYPE type = _LOG_NORMAL);
void WriteDebugLog(CString Str,CString ValName1,CString ValName2,double val1,double val2);
void WriteDebugLog(CString Str,CString ValName,double val);
void WriteByte(BYTE bit);
void SetbWriteDebugLog(bool b){m_bWriteDebugLog = b;};
void WriteBuf(char *buf,int len);
CString GetLogFilePath();
void UpdateLogFileStream();
void OpenLogFileDir();
void WritePromptInfo(CString Str);
int GetMaxWorkRecodCnt(){return m_MaxWorkRecodCnt;};
CString GetLastLogStr();
void OpenLogListApp();
private:
void CreatLogFilePath();
CString GetLogPath();
void OpenLogListAppExt();
private:
COutputWnd * m_pOutputLog;//日志输出
COutputWnd * m_pPromptInfo;//提示信息
bool m_bWriteDebugLog;//是否输出日志文件
bool m_bWriteToLogList;//输出到日志列表
int m_LogListMaxLine;//日志列表最大的行数,超过时清空
int m_MaxWorkRecodCnt;//最大加工记录的查询数量,避免数量过大卡死
ofstream m_LogFileStream;//用于debug 的日志文件
ofstream m_ResultFile;//用于记录特殊输出的文件
CString m_LastLogStr;//最近的一条日志
bool m_bNotWriteSameLog;//不要显示连续相同的日志
CString m_CurDebugLogFilePath;//日志文件路径,用来判断是否需要更新日志路径
};
extern CLogMgr* gLogMgr;