mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 05:51:23 +08:00
refs #467 CFileLogger must not use CLogSubscriber or CLogPatternHandler because this would cause undesired dbus traffic.
This commit is contained in:
@@ -21,7 +21,6 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CFileLogger::CFileLogger(const QString &applicationName, const QString &logPath, QObject *parent) :
|
CFileLogger::CFileLogger(const QString &applicationName, const QString &logPath, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_logSubscriber(this, &CFileLogger::ps_writeStatusMessageToFile),
|
|
||||||
m_logFile(this),
|
m_logFile(this),
|
||||||
m_applicationName(applicationName),
|
m_applicationName(applicationName),
|
||||||
m_logPath(logPath)
|
m_logPath(logPath)
|
||||||
@@ -34,6 +33,9 @@ namespace BlackMisc
|
|||||||
m_stream.setDevice(&m_logFile);
|
m_stream.setDevice(&m_logFile);
|
||||||
m_stream.setCodec("UTF-8");
|
m_stream.setCodec("UTF-8");
|
||||||
writeHeaderToFile();
|
writeHeaderToFile();
|
||||||
|
|
||||||
|
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, &CFileLogger::ps_writeStatusMessageToFile);
|
||||||
|
connect(CLogHandler::instance(), &CLogHandler::remoteMessageLogged, this, &CFileLogger::ps_writeStatusMessageToFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFileLogger::~CFileLogger()
|
CFileLogger::~CFileLogger()
|
||||||
@@ -45,13 +47,10 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFileLogger::changeLogPattern(const CLogPattern &pattern)
|
|
||||||
{
|
|
||||||
m_logSubscriber.changeSubscription(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFileLogger::ps_writeStatusMessageToFile(const BlackMisc::CStatusMessage &statusMessage)
|
void CFileLogger::ps_writeStatusMessageToFile(const BlackMisc::CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
|
if (! m_logPattern.match(statusMessage)) { return; }
|
||||||
|
|
||||||
QString finalContent = QDateTime::currentDateTime().toString(QStringLiteral("hh:mm:ss "));
|
QString finalContent = QDateTime::currentDateTime().toString(QStringLiteral("hh:mm:ss "));
|
||||||
finalContent += statusMessage.getHumanReadableCategory();
|
finalContent += statusMessage.getHumanReadableCategory();
|
||||||
finalContent += " ";
|
finalContent += " ";
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ namespace BlackMisc
|
|||||||
//! Destructor.
|
//! Destructor.
|
||||||
~CFileLogger();
|
~CFileLogger();
|
||||||
|
|
||||||
//! Change the log pattern. Call this method at least once to start logging
|
//! Change the log pattern. Default is to log all messages.
|
||||||
void changeLogPattern(const CLogPattern &pattern);
|
void changeLogPattern(const CLogPattern &pattern) { m_logPattern = pattern; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
|||||||
void writeHeaderToFile();
|
void writeHeaderToFile();
|
||||||
void writeContentToFile(const QString &content);
|
void writeContentToFile(const QString &content);
|
||||||
|
|
||||||
CLogSubscriber m_logSubscriber;
|
CLogPattern m_logPattern;
|
||||||
QFile m_logFile;
|
QFile m_logFile;
|
||||||
QTextStream m_stream;
|
QTextStream m_stream;
|
||||||
QString m_applicationName;
|
QString m_applicationName;
|
||||||
|
|||||||
Reference in New Issue
Block a user