feat: merge the UserOperationLog and SystemOperationLog in LogManager.
This commit is contained in:
47
src/log/LogManager.cpp
Normal file
47
src/log/LogManager.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "LogManager.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
LogManager* LogManager::getInstance()
|
||||
{
|
||||
static LogManager instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
LogManager::LogManager()
|
||||
: QObject()
|
||||
, mThread(new QThread())
|
||||
, mSysLog(new SystemOperationLog())
|
||||
, mUserLog(new UserOperationLog())
|
||||
{
|
||||
mSysLog->moveToThread(mThread);
|
||||
mUserLog->moveToThread(mThread);
|
||||
connect(this, &LogManager::doWriteSystemOperationLog, mSysLog, &SystemOperationLog::log);
|
||||
connect(this, &LogManager::doWriteUserOperationLog, mUserLog, &UserOperationLog::log);
|
||||
mThread->start();
|
||||
}
|
||||
|
||||
LogManager::~LogManager()
|
||||
{
|
||||
mThread->quit();
|
||||
mThread->wait();
|
||||
|
||||
delete mUserLog;
|
||||
delete mSysLog;
|
||||
mThread->deleteLater();
|
||||
}
|
||||
|
||||
void LogManager::writeSystemOperationLog(const QString& aMessage)
|
||||
{
|
||||
emit doWriteSystemOperationLog(aMessage);
|
||||
}
|
||||
|
||||
void LogManager::writeUserOperationLog(const QString& aMessage)
|
||||
{
|
||||
emit doWriteUserOperationLog(aMessage);
|
||||
}
|
||||
|
||||
QString LogManager::getCurrentUserOperationLogFile()
|
||||
{
|
||||
return mUserLog->currentLogFile();
|
||||
}
|
||||
Reference in New Issue
Block a user