Issue #77 Break cyclic dependency between CStatusMessage and CLogPattern by moving methods from one to the other

This commit is contained in:
Mat Sutcliffe
2020-11-07 22:34:25 +00:00
parent 211fd42eaf
commit 3d129dc83f
8 changed files with 29 additions and 41 deletions

View File

@@ -71,6 +71,23 @@ namespace BlackMisc
return names;
}
QStringList CLogPattern::humanReadableNamesFrom(const CStatusMessage &message)
{
QStringList patternNames;
for (const QString &name : CLogPattern::allHumanReadableNames())
{
if (CLogPattern::fromHumanReadableName(name).match(message)) { patternNames.push_back(name); }
}
return patternNames;
}
QStringList CLogPattern::humanOrTechnicalCategoriesFrom(const CStatusMessage &message)
{
if (message.getCategories().isEmpty()) { return {}; }
QStringList c(humanReadableNamesFrom(message).join(", "));
return c.isEmpty() ? message.getCategories().toQStringList() : c;
}
const CLogPattern &CLogPattern::fromHumanReadableName(const QString &name)
{
static const CLogPattern empty {};