Ref T485 Adjust CLogMessage and CStatusMessage call sites to use the new API.

This commit is contained in:
Mat Sutcliffe
2018-12-23 20:12:49 +00:00
parent cba820cbce
commit 225ff81252
118 changed files with 724 additions and 721 deletions

View File

@@ -162,18 +162,18 @@ namespace BlackMisc
{
if (!this->hasExistingCorrespondingFile())
{
const CStatusMessage m = CStatusMessage(this).validationWarning("File '%1' not readable") << this->getFileName();
const CStatusMessage m = CStatusMessage(this).validationWarning(u"File '%1' not readable") << this->getFileName();
msgs.push_back(m);
}
else
{
const CStatusMessage m = CStatusMessage(this).validationInfo("File '%1' existing") << this->getFileName();
const CStatusMessage m = CStatusMessage(this).validationInfo(u"File '%1' existing") << this->getFileName();
msgs.push_back(m);
}
}
else
{
const CStatusMessage m = CStatusMessage(this).validationError("Invalid model type to check: '%1'") << this->getModelTypeAsString();
const CStatusMessage m = CStatusMessage(this).validationError(u"Invalid model type to check: '%1'") << this->getModelTypeAsString();
msgs.push_back(m);
}
return msgs;

View File

@@ -1066,7 +1066,7 @@ namespace BlackMisc
// Any DB distributors?
if (distributorsFromDb.isEmpty())
{
const CStatusMessage msg = CStatusMessage(this).validationError("No DB distributors for validation");
const CStatusMessage msg = CStatusMessage(this).validationError(u"No DB distributors for validation");
msgs.push_back(msg);
invalidModels.push_back(*this);
return msgs;
@@ -1080,7 +1080,7 @@ namespace BlackMisc
}
else
{
const CStatusMessage msg = CStatusMessage(this).validationError("No valid distributor for '%1', was '%2'") << model.getModelString() << model.getDistributor().getDbKey();
const CStatusMessage msg = CStatusMessage(this).validationError(u"No valid distributor for '%1', was '%2'") << model.getModelString() << model.getDistributor().getDbKey();
msgs.push_back(msg);
invalidModels.push_back(model);
}

View File

@@ -214,11 +214,11 @@ namespace BlackMisc
if (statusMsgs.hasWarningOrErrorMessages())
{
CLogMessage(this).log(m_loadingMessages.worstSeverity(),
"Message loading produced %1 error and %2 warning messages") << errors << warnings;
u"Message loading produced %1 error and %2 warning messages") << errors << warnings;
}
else
{
CLogMessage(this).info("Loading '%1' finished, success for '%2'") << IAircraftModelLoader::enumToString(info) << simulator.toQString();
CLogMessage(this).info(u"Loading '%1' finished, success for '%2'") << IAircraftModelLoader::enumToString(info) << simulator.toQString();
}
}

View File

@@ -182,12 +182,12 @@ namespace BlackMisc
if (synchronizeCache)
{
this->synchronizeCacheImpl(sim);
CLogMessage(this).info("Initialized model caches (%1) for %2") << this->getDescription() << simStr;
CLogMessage(this).info(u"Initialized model caches (%1) for %2") << this->getDescription() << simStr;
}
else
{
this->admitCacheImpl(sim);
CLogMessage(this).info("Admit model (%1) caches for %2") << this->getDescription() << simStr;
CLogMessage(this).info(u"Admit model (%1) caches for %2") << this->getDescription() << simStr;
}
}
@@ -293,7 +293,7 @@ namespace BlackMisc
CStatusMessage CModelCaches::setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
if (!ts.isValid()) { return CStatusMessage(this).error("Invalid timestamp for '%1'") << simulator.toQString() ; }
if (!ts.isValid()) { return CStatusMessage(this).error(u"Invalid timestamp for '%1'") << simulator.toQString() ; }
switch (simulator.getSimulator())
{
case CSimulatorInfo::FS9: return m_modelCacheFs9.set(m_modelCacheFs9.get(), ts.toMSecsSinceEpoch());
@@ -398,12 +398,12 @@ namespace BlackMisc
if (synchronizeCache)
{
this->synchronizeCacheImpl(simulator);
CLogMessage(this).info("Initialized model caches (%1) for %2") << this->getDescription() << simStr;
CLogMessage(this).info(u"Initialized model caches (%1) for %2") << this->getDescription() << simStr;
}
else
{
this->admitCacheImpl(simulator);
CLogMessage(this).info("Admit model (%1) caches for %2") << this->getDescription() << simStr;
CLogMessage(this).info(u"Admit model (%1) caches for %2") << this->getDescription() << simStr;
}
}
@@ -478,7 +478,7 @@ namespace BlackMisc
CStatusMessage CModelSetCaches::setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
if (!ts.isValid()) { return CStatusMessage(this).error("Invalid timestamp for '%1'") << simulator.toQString() ; }
if (!ts.isValid()) { return CStatusMessage(this).error(u"Invalid timestamp for '%1'") << simulator.toQString() ; }
switch (simulator.getSimulator())
{
case CSimulatorInfo::FS9: return m_modelCacheFs9.set(m_modelCacheFs9.get(), ts.toMSecsSinceEpoch());

View File

@@ -85,7 +85,7 @@ namespace BlackMisc
if (keys.contains(key))
{
CStatusMessage msg(this);
msg.warning("Duplicate model string %1 in %2 %3")
msg.warning(u"Duplicate model string %1 in %2 %3")
<< entries.getTitle() << entries.getFileDirectory() << entries.getFileName();
msgs.push_back(msg);
continue;

View File

@@ -184,7 +184,7 @@ namespace BlackMisc
}
else
{
const CStatusMessage m = CStatusMessage(this).warning("Parsing failed for '%1'") << nextDir;
const CStatusMessage m = CStatusMessage(this).warning(u"Parsing failed for '%1'") << nextDir;
messages.push_back(m);
}
}
@@ -200,7 +200,7 @@ namespace BlackMisc
CAircraftCfgEntriesList fileResults = CAircraftCfgParser::performParsingOfSingleFile(fileName, fileOk, fileMsgs);
if (!fileOk)
{
const CStatusMessage m = CStatusMessage(this).warning("Parsing of '%1' failed") << fileName;
const CStatusMessage m = CStatusMessage(this).warning(u"Parsing of '%1' failed") << fileName;
messages.push_back(fileMsgs);
continue;
}
@@ -226,7 +226,7 @@ namespace BlackMisc
QFile file(fnFixed); // includes path
if (!file.open(QFile::ReadOnly | QFile::Text))
{
const CStatusMessage m = CStatusMessage(getLogCategories()).warning("Unable to read file '%1'") << fnFixed;
const CStatusMessage m = CStatusMessage(getLogCategories()).warning(u"Unable to read file '%1'") << fnFixed;
msgs.push_back(m);
return CAircraftCfgEntriesList();
}
@@ -366,7 +366,7 @@ namespace BlackMisc
{
if (e.getTitle().isEmpty())
{
const CStatusMessage m = CStatusMessage(getLogCategories()).info("FS model in %1, index %2 has no title") << fileName << e.getIndex();
const CStatusMessage m = CStatusMessage(getLogCategories()).info(u"FS model in %1, index %2 has no title") << fileName << e.getIndex();
msgs.push_back(m);
continue;
}

View File

@@ -93,7 +93,7 @@ namespace BlackMisc
CStatusMessageList CInterpolationLogger::writeLogFile(const QList<SituationLog> &interpolation, const QList<PartsLog> &parts)
{
if (parts.isEmpty() && interpolation.isEmpty()) { return CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).warning("No data for log"); }
if (parts.isEmpty() && interpolation.isEmpty()) { return CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).warning(u"No data for log"); }
static const QString html = QStringLiteral("Entries: %1\n\n%2");
const QString htmlTemplate = CFileUtils::readFileToString(CDirectoryUtils::htmlTemplateFilePath());
@@ -124,8 +124,8 @@ namespace BlackMisc
CStatusMessage CInterpolationLogger::logStatusFileWriting(bool success, const QString &fileName)
{
return success ?
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).info("Written log file '%1'") << fileName :
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).error("Failed to write log file '%1'") << fileName;
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).info(u"Written log file '%1'") << fileName :
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).error(u"Failed to write log file '%1'") << fileName;
}
void CInterpolationLogger::logInterpolation(const SituationLog &log)

View File

@@ -265,13 +265,13 @@ namespace BlackMisc
CStatusMessage m;
if (noSituation)
{
m = CStatusMessage(this).warning("No situation #%1 for interpolation reported for '%2' (Interpolant: %3 interpolation: %4)") <<
m = CStatusMessage(this).warning(u"No situation #%1 for interpolation reported for '%2' (Interpolant: %3 interpolation: %4)") <<
m_invalidSituations << m_callsign.asString() << boolToTrueFalse(isValidInterpolant) << boolToTrueFalse(isValidInterpolation);
}
else
{
const qint64 diff = noSituation ? -1 : m_currentTimeMsSinceEpoch - currentSituation.getAdjustedMSecsSinceEpoch();
m = CStatusMessage(this).warning("Invalid situation, diff. %1ms #%2 for interpolation reported for '%3' (Interpolant: %4 interpolation: %5)") <<
m = CStatusMessage(this).warning(u"Invalid situation, diff. %1ms #%2 for interpolation reported for '%3' (Interpolant: %4 interpolation: %5)") <<
diff << m_invalidSituations << m_callsign.asString() << boolToTrueFalse(isValidInterpolant) << boolToTrueFalse(isValidInterpolation);
}
if (!m.isEmpty())
@@ -417,7 +417,7 @@ namespace BlackMisc
if (log)
{
const CStatusMessage m = CStatusMessage(this).warning("NULL parts reported for '%1', '%2')") << m_callsign.asString() << info;
const CStatusMessage m = CStatusMessage(this).warning(u"NULL parts reported for '%1', '%2')") << m_callsign.asString() << info;
if (m_interpolationMessages.isEmpty()) { CLogMessage::preformatted(m); }
m_interpolationMessages.push_back(m);
}

View File

@@ -175,7 +175,7 @@ namespace BlackMisc
{
if (models.containsModelString(model.getModelString()))
{
CLogMessage(static_cast<CAircraftModelLoaderXPlane *>(nullptr)).warning("XPlane model '%1' exists already! Potential model string conflict! Ignoring it.") << model.getModelString();
CLogMessage(static_cast<CAircraftModelLoaderXPlane *>(nullptr)).warning(u"XPlane model '%1' exists already! Potential model string conflict! Ignoring it.") << model.getModelString();
}
models.push_back(model);
}
@@ -270,7 +270,7 @@ namespace BlackMisc
{
if (installedModels.containsModelString(plane.getModelName()))
{
const CStatusMessage msg = CStatusMessage(this).warning("XPlane model '%1' exists already! Potential model string conflict! Ignoring it.") << plane.getModelName();
const CStatusMessage msg = CStatusMessage(this).warning(u"XPlane model '%1' exists already! Potential model string conflict! Ignoring it.") << plane.getModelName();
m_loadingMessages.push_back(msg);
continue;
}
@@ -316,7 +316,7 @@ namespace BlackMisc
{
if (tokens.size() != 2)
{
CLogMessage(this).error("XPlane '%1' - '%2': EXPORT_NAME command requires 1 argument.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': EXPORT_NAME command requires 1 argument.") << path << lineNum;
return false;
}
@@ -329,7 +329,7 @@ namespace BlackMisc
}
else
{
CLogMessage(this).error("XPlane package name '%1' already in use by '%2' reqested by use by '%3'") << tokens[1] << p->path << path;
CLogMessage(this).error(u"XPlane package name '%1' already in use by '%2' reqested by use by '%3'") << tokens[1] << p->path << path;
return false;
}
}
@@ -339,13 +339,13 @@ namespace BlackMisc
Q_UNUSED(package);
if (tokens.size() != 2)
{
CLogMessage(this).error("'%1' - '%2': DEPENDENCY command requires 1 argument.") << path << lineNum;
CLogMessage(this).error(u"'%1' - '%2': DEPENDENCY command requires 1 argument.") << path << lineNum;
return false;
}
if (std::count_if(m_cslPackages.cbegin(), m_cslPackages.cend(), [&tokens](const CSLPackage & p) { return p.name == tokens[1]; }) == 0)
{
CLogMessage(this).error("XPlane required package %1 not found. Aborting processing of this package.") << tokens[1];
CLogMessage(this).error(u"XPlane required package %1 not found. Aborting processing of this package.") << tokens[1];
return false;
}
@@ -369,7 +369,7 @@ namespace BlackMisc
{
if (tokens.size() != 2)
{
CLogMessage(this).error("XPlane '%1' - '%2': OBJECT command requires 1 argument.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': OBJECT command requires 1 argument.") << path << lineNum;
return false;
}
@@ -378,7 +378,7 @@ namespace BlackMisc
QString fullPath(relativePath);
if (!doPackageSub(fullPath))
{
CLogMessage(this).error("XPlane '%1' - '%2: package not found.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2: package not found.") << path << lineNum;
return false;
}
@@ -386,7 +386,7 @@ namespace BlackMisc
QFile objFile(fullPath);
if (!objFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
CLogMessage(this).error("XPlane object '%1' does not exist.") << fullPath;
CLogMessage(this).error(u"XPlane object '%1' does not exist.") << fullPath;
return false;
}
QTextStream ts(&objFile);
@@ -432,7 +432,7 @@ namespace BlackMisc
{
if (tokens.size() != 2)
{
CLogMessage(this).error("XPlane '%1' - '%2': TEXTURE command requires 1 argument.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': TEXTURE command requires 1 argument.") << path << lineNum;
return false;
}
@@ -443,14 +443,14 @@ namespace BlackMisc
if (!doPackageSub(absoluteTexPath))
{
CLogMessage(this).error("XPlane '%1' - '%2': package not found.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': package not found.") << path << lineNum;
return false;
}
QFileInfo fileInfo(absoluteTexPath);
if (!fileInfo.exists())
{
CLogMessage(this).error("XPlane texture '%1' does not exist.") << absoluteTexPath;
CLogMessage(this).error(u"XPlane texture '%1' does not exist.") << absoluteTexPath;
return false;
}
@@ -464,12 +464,12 @@ namespace BlackMisc
// AIRCAFT <min> <max> <path>
if (tokens.size() != 4)
{
CLogMessage(this).error("XPlane '%1' - '%2': AIRCRAFT command requires 3 arguments.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': AIRCRAFT command requires 3 arguments.") << path << lineNum;
}
// Flyable aircrafts are parsed by a different method. We don't know any aircraft files in CSL packages.
// If there is one, implement this method here.
CLogMessage(this).warning("Not implemented yet.");
CLogMessage(this).warning(u"Not implemented yet.");
return true;
}
@@ -478,7 +478,7 @@ namespace BlackMisc
// OBJ8_AIRCRAFT <path>
if (tokens.size() != 2)
{
CLogMessage(this).error("XPlane '%1' - '%2': OBJ8_AIRCARFT command requires 1 argument.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': OBJ8_AIRCARFT command requires 1 argument.") << path << lineNum;
}
package.planes.push_back(CSLPlane());
@@ -490,7 +490,7 @@ namespace BlackMisc
// OBJ8 <group> <animate YES|NO> <filename> {<texture filename> {<lit texture filename>}}
if (tokens.size() < 4 || tokens.size() > 6)
{
CLogMessage(this).error("XPlane '%1' - '%2': OBJ8 command takes 3-5 arguments.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': OBJ8 command takes 3-5 arguments.") << path << lineNum;
}
if (tokens[1] != "SOLID") { return true; }
@@ -500,7 +500,7 @@ namespace BlackMisc
QString fullPath(relativePath);
if (!doPackageSub(fullPath))
{
CLogMessage(this).error("XPlane '%1' - '%2': package not found.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': package not found.") << path << lineNum;
return false;
}
@@ -529,14 +529,14 @@ namespace BlackMisc
if (!doPackageSub(absoluteTexPath))
{
CLogMessage(this).error("XPlane '%1' - '%2': package not found.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': package not found.") << path << lineNum;
return false;
}
QFileInfo fileInfo(absoluteTexPath);
if (!fileInfo.exists())
{
CLogMessage(this).error("XPlane texture '%1' does not exist.") << absoluteTexPath;
CLogMessage(this).error(u"XPlane texture '%1' does not exist.") << absoluteTexPath;
return false;
}
@@ -559,7 +559,7 @@ namespace BlackMisc
// ICAO <code>
if (tokens.size() != 2)
{
CLogMessage(this).error("XPlane '%1' - '%2': ICAO command requires 1 argument.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': ICAO command requires 1 argument.") << path << lineNum;
return false;
}
@@ -573,7 +573,7 @@ namespace BlackMisc
// AIRLINE <code> <airline>
if (tokens.size() != 3)
{
CLogMessage(this).error("XPlane '%1' - '%2': AIRLINE command requires 2 arguments.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': AIRLINE command requires 2 arguments.") << path << lineNum;
return false;
}
@@ -589,7 +589,7 @@ namespace BlackMisc
// LIVERY <code> <airline> <livery>
if (tokens.size() != 4)
{
CLogMessage(this).error("XPlane '%1' - '%2': LIVERY command requires 3 arguments.") << path << lineNum;
CLogMessage(this).error(u"XPlane '%1' - '%2': LIVERY command requires 3 arguments.") << path << lineNum;
return false;
}
@@ -681,14 +681,14 @@ namespace BlackMisc
bool result = it.value()(tokens, package, package.path, lineNum);
if (!result)
{
const CStatusMessage m = CStatusMessage(this).warning("XPlane ignoring CSL package '%1'") << package.name;
const CStatusMessage m = CStatusMessage(this).warning(u"XPlane ignoring CSL package '%1'") << package.name;
m_loadingMessages.push_back(m);
break;
}
}
else
{
const CStatusMessage m = CStatusMessage(this).warning("XPlane unrecognized command '%1' in '%2'") << tokens[0] << package.name;
const CStatusMessage m = CStatusMessage(this).warning(u"XPlane unrecognized command '%1' in '%2'") << tokens[0] << package.name;
m_loadingMessages.push_back(m);
break;
}