mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Add CFileLogger convenience methods to get log file name and file path
ref T401
This commit is contained in:
committed by
Mat Sutcliffe
parent
0381b45a87
commit
4ca1f46f74
@@ -88,16 +88,17 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QString CFileLogger::getFullFileName()
|
QString CFileLogger::getFullFileName()
|
||||||
{
|
{
|
||||||
QString filename;
|
QString filePath;
|
||||||
Q_ASSERT(!m_applicationName.isEmpty());
|
Q_ASSERT(!m_applicationName.isEmpty());
|
||||||
if (!m_logPath.isEmpty()) filename += m_logPath;
|
if (!m_logPath.isEmpty()) filePath += m_logPath;
|
||||||
filename += m_applicationName;
|
|
||||||
filename += QLatin1String("_");
|
m_fileName += m_applicationName;
|
||||||
filename += QDateTime::currentDateTime().toString(QStringLiteral("yyMMddhhmmss"));
|
m_fileName += QLatin1String("_");
|
||||||
filename += QLatin1String("_");
|
m_fileName += QDateTime::currentDateTime().toString(QStringLiteral("yyMMddhhmmss"));
|
||||||
filename += QString::number(QCoreApplication::applicationPid());
|
m_fileName += QLatin1String("_");
|
||||||
filename += QLatin1String(".log");
|
m_fileName += QString::number(QCoreApplication::applicationPid());
|
||||||
return filename;
|
m_fileName += QLatin1String(".log");
|
||||||
|
return filePath + m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFileLogger::removeOldLogFiles()
|
void CFileLogger::removeOldLogFiles()
|
||||||
|
|||||||
@@ -52,12 +52,17 @@ namespace BlackMisc
|
|||||||
//! Close file
|
//! Close file
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
//! Get the current log file path
|
||||||
|
QString getLogFilePath() const { return m_logFile.fileName(); }
|
||||||
|
|
||||||
|
//! Get the current log file name
|
||||||
|
QString getLogFileName() const { return m_fileName; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Write single status message to file
|
//! Write single status message to file
|
||||||
void ps_writeStatusMessageToFile(const BlackMisc::CStatusMessage &statusMessage);
|
void ps_writeStatusMessageToFile(const BlackMisc::CStatusMessage &statusMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString getFullFileName();
|
QString getFullFileName();
|
||||||
void removeOldLogFiles();
|
void removeOldLogFiles();
|
||||||
|
|
||||||
@@ -66,6 +71,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CLogPattern m_logPattern;
|
CLogPattern m_logPattern;
|
||||||
QFile m_logFile;
|
QFile m_logFile;
|
||||||
|
QString m_fileName;
|
||||||
QTextStream m_stream;
|
QTextStream m_stream;
|
||||||
QString m_applicationName;
|
QString m_applicationName;
|
||||||
QString m_logPath; //!< Empty by default. Hence the working directory "." is used
|
QString m_logPath; //!< Empty by default. Hence the working directory "." is used
|
||||||
|
|||||||
Reference in New Issue
Block a user