mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
Ref T171, interpolation logger pattern functions
This commit is contained in:
@@ -63,13 +63,13 @@ namespace BlackMisc
|
|||||||
const QString logDir = CDirectoryUtils::logDirectory();
|
const QString logDir = CDirectoryUtils::logDirectory();
|
||||||
QDir logs(logDir);
|
QDir logs(logDir);
|
||||||
if (!logs.exists()) { return files; }
|
if (!logs.exists()) { return files; }
|
||||||
logs.setNameFilters(QStringList() << "*interpolation.html" << "*parts.html");
|
logs.setNameFilters(filePatterns());
|
||||||
const QStringList interpolations = logs.entryList(QStringList({"*interpolation.html"}), QDir::NoFilter, QDir::Time);
|
const QStringList interpolations = logs.entryList(QStringList({filePatternInterpolationLog()}), QDir::NoFilter, QDir::Time);
|
||||||
if (!interpolations.isEmpty())
|
if (!interpolations.isEmpty())
|
||||||
{
|
{
|
||||||
files[0] = CFileUtils::appendFilePaths(logDir, interpolations.first());
|
files[0] = CFileUtils::appendFilePaths(logDir, interpolations.first());
|
||||||
}
|
}
|
||||||
const QStringList parts = logs.entryList(QStringList({"*parts.html"}), QDir::NoFilter, QDir::Time);
|
const QStringList parts = logs.entryList(QStringList({filePatternPartsLog()}), QDir::NoFilter, QDir::Time);
|
||||||
if (!parts.isEmpty())
|
if (!parts.isEmpty())
|
||||||
{
|
{
|
||||||
files[1] = CFileUtils::appendFilePaths(logDir, parts.first());
|
files[1] = CFileUtils::appendFilePaths(logDir, parts.first());
|
||||||
@@ -93,7 +93,9 @@ namespace BlackMisc
|
|||||||
const QString htmlInterpolation = CInterpolationLogger::getHtmlInterpolationLog(interpolation);
|
const QString htmlInterpolation = CInterpolationLogger::getHtmlInterpolationLog(interpolation);
|
||||||
if (!htmlInterpolation.isEmpty())
|
if (!htmlInterpolation.isEmpty())
|
||||||
{
|
{
|
||||||
const QString fn = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), QString("%1 interpolation.html").arg(ts));
|
QString file = filePatternInterpolationLog();
|
||||||
|
file.remove('*');
|
||||||
|
const QString fn = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), QString("%1 %2").arg(ts, file));
|
||||||
const bool s = CFileUtils::writeStringToFile(htmlTemplate.arg(html.arg(interpolation.size()).arg(htmlInterpolation)), fn);
|
const bool s = CFileUtils::writeStringToFile(htmlTemplate.arg(html.arg(interpolation.size()).arg(htmlInterpolation)), fn);
|
||||||
msgs.push_back(CInterpolationLogger::logStatusFileWriting(s, fn));
|
msgs.push_back(CInterpolationLogger::logStatusFileWriting(s, fn));
|
||||||
}
|
}
|
||||||
@@ -101,7 +103,9 @@ namespace BlackMisc
|
|||||||
const QString htmlParts = CInterpolationLogger::getHtmlPartsLog(parts);
|
const QString htmlParts = CInterpolationLogger::getHtmlPartsLog(parts);
|
||||||
if (!htmlParts.isEmpty())
|
if (!htmlParts.isEmpty())
|
||||||
{
|
{
|
||||||
const QString fn = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), QString("%1 parts.html").arg(ts));
|
QString file = filePatternPartsLog();
|
||||||
|
file.remove('*');
|
||||||
|
const QString fn = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), QString("%1 %2").arg(ts, file));
|
||||||
const bool s = CFileUtils::writeStringToFile(htmlTemplate.arg(html.arg(parts.size()).arg(htmlParts)), fn);
|
const bool s = CFileUtils::writeStringToFile(htmlTemplate.arg(html.arg(parts.size()).arg(htmlParts)), fn);
|
||||||
msgs.push_back(CInterpolationLogger::logStatusFileWriting(s, fn));
|
msgs.push_back(CInterpolationLogger::logStatusFileWriting(s, fn));
|
||||||
}
|
}
|
||||||
@@ -127,6 +131,24 @@ namespace BlackMisc
|
|||||||
m_partsLogs.append(parts);
|
m_partsLogs.append(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CInterpolationLogger::filePatternInterpolationLog()
|
||||||
|
{
|
||||||
|
static const QString p("*interpolation.html");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CInterpolationLogger::filePatternPartsLog()
|
||||||
|
{
|
||||||
|
static const QString p("*parts.html");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList &CInterpolationLogger::filePatterns()
|
||||||
|
{
|
||||||
|
static const QStringList l({ filePatternInterpolationLog(), filePatternPartsLog() });
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
QString CInterpolationLogger::getHtmlInterpolationLog(const QList<SituationLog> &logs)
|
QString CInterpolationLogger::getHtmlInterpolationLog(const QList<SituationLog> &logs)
|
||||||
{
|
{
|
||||||
if (logs.isEmpty()) { return {}; }
|
if (logs.isEmpty()) { return {}; }
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QStringList>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -88,6 +88,15 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void logParts(const PartsLog &parts);
|
void logParts(const PartsLog &parts);
|
||||||
|
|
||||||
|
//! File pattern for interpolation log
|
||||||
|
static const QString &filePatternInterpolationLog();
|
||||||
|
|
||||||
|
//! File pattern for parts log
|
||||||
|
static const QString &filePatternPartsLog();
|
||||||
|
|
||||||
|
//! All log.file patterns
|
||||||
|
static const QStringList &filePatterns();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Get log as HTML table
|
//! Get log as HTML table
|
||||||
static QString getHtmlInterpolationLog(const QList<SituationLog> &logs);
|
static QString getHtmlInterpolationLog(const QList<SituationLog> &logs);
|
||||||
|
|||||||
Reference in New Issue
Block a user