56class MDWC_COMPLILE CAppLogger
60 std::ofstream m_fsLogFileObj;
62 std::string m_sLogFileName;
64 std::string m_sAppIdentity;
66 std::string m_sExecPath;
68 std::tm m_LogFileDate;
70 std::thread *m_thrProcLog;
72 bool m_bWriteDebugLog;
74 std::list<AppLogMsg> m_LogMsgQueue;
76 std::mutex m_queueMutex;
78 std::mutex m_fileMutex;
80 std::condition_variable m_cvHavelLogMsg;
82 std::atomic<bool> m_bStopThread;
84 int64_t m_iLastWriteFileTime;
86 std::chrono::system_clock::time_point m_tLastLogTime;
88 int m_iLogFileRetentionDays;
91 QString m_sLastLogMessage;
94 std::atomic<bool> m_bSendShowNotify;
96 QObject* m_pShowLogWnd;
98 SHOW_MSGBUFS* m_lstNotShowLogMsg;
100 QMutex* m_MutexShowLog;
102 std::string m_sLastLogMessage;
106 CAppLogger(
const CAppLogger&) =
delete;
108 CAppLogger& operator=(
const CAppLogger&) =
delete;
116 void AddShowLogMessage(LOG_MSG_TYPE eLogType,
const std::string& sLogMessage);
118 void NotifyShowMessage();
132 bool WriteFinished();
134 void ClearFloderLogFile();
136 void CreateLogFile();
140 void WriteLogMsgToFile();
154 void WriteLog(
const std::string& sFunctionName,
const std::string& sLogMsg);
162 void WriteLog(
const std::string& sFunctionName,
const char* fmt, ...);
170 void WriteDebug(
const std::string& sFunctionName,
const std::string& sLogMsg);
177 void WriteDebug(
const std::string& sFunctionName,
const char* fmt, ...);
185 void WriteDebugCompile(
const std::string& sFunctionName,
const char* fmt, ...);
193 void WriteErrorLog(
const std::string& sFunctionName,
const std::string& sLogMsg);
200 void WriteErrorLog(
const std::string& sFunctionName,
const char* fmt, ...);
208 void WriteWaringLog(
const std::string& sFunctionName,
const std::string& sLogMsg);
215 void WriteWaringLog(
const std::string& sFunctionName,
const char* fmt, ...);
223 void WriteExceptionLog(
const std::string& sFunctionName,
const std::exception& ex);
232 void WriteLog(
const QString& usFunctionName,
const QString& usLogMsg)
234 WriteLog(usFunctionName.toStdString(), usLogMsg.toStdString());
243 void WriteDebug(
const QString& sFunctionName,
const QString& sLogMsg)
245 return WriteDebug(sFunctionName.toStdString(), sLogMsg.toStdString());
254 void WriteDebugCompile(
const QString& sFunctionName,
const QString& sLogMsg)
257 return WriteDebug(sFunctionName.toStdString(), sLogMsg.toStdString());
270 void WriteErrorLog(
const QString& sFunctionName,
const QString& sLogMsg)
272 return WriteErrorLog(sFunctionName.toStdString(), sLogMsg.toStdString());
281 void WriteWaringLog(
const QString& sFunctionName,
const QString& sLogMsg)
283 return WriteWaringLog(sFunctionName.toStdString(), sLogMsg.toStdString());
290 QString GetLastLogMessage()
292 std::lock_guard<std::mutex> lock(m_queueMutex);
293 return m_sLastLogMessage;
298 std::lock_guard<std::mutex> lock(m_queueMutex);
299 return m_sLastLogMessage;
307 void StartAppLogger();
309 void StopAppLogger();
321 CAppLogger(
const std::string& sAppIdentity,
const std::string& sWorkDirectory =
"",
int iLogFileRetentionDays = 100);
329 CAppLogger(
const QString& usAppIdentity,
const QString& usWorkDirectory =
"",
int iLogFileRetentionDays = 100)
330 :
CAppLogger(usAppIdentity.toStdString(), usWorkDirectory.toStdString(), iLogFileRetentionDays)
339 void SetShowLogPara(QObject* pShowLogWnd, SHOW_MSGBUFS* lstNotShowLogMsg, QMutex* pMutexShowLog);