56 {
"uncategorized (default)",
exactMatch(
"default") },
57 {
"uncategorized (none)",
empty() }
64 static const QStringList names = allHumanReadablePatterns().keys();
70 QStringList patternNames;
88 auto it = allHumanReadablePatterns().find(name);
89 return it == allHumanReadablePatterns().end() ?
empty : *it;
103 return { ExactMatch, { category.
toQString() } };
108 if (categories.
size() == 0) {
return empty(); }
111 return { AnyOf, QSet<QString>(strList.begin(), strList.end()) };
116 if (categories.
size() == 0) {
return {}; }
119 return { AnyOf, QSet<QString>(strList.begin(), strList.end()) };
133 result.m_severities = { severity };
140 result.m_severities = severities;
147 result.m_severities.clear();
148 switch (minimumSeverity)
161 bool CLogPattern::checkInvariants()
const
165 case Everything:
return m_strings.isEmpty();
166 case ExactMatch:
return m_strings.size() == 1;
167 case AnyOf:
return m_strings.size() > 1;
168 case AllOf:
return m_strings.size() > 1;
169 case StartsWith:
return m_strings.size() == 1;
170 case EndsWith:
return m_strings.size() == 1;
171 case Contains:
return m_strings.size() == 1;
172 case Nothing:
return m_strings.isEmpty();
173 default:
return false;
179 if (!checkInvariants())
185 if (!m_severities.contains(message.
getSeverity())) {
return false; }
190 case Everything:
return true;
193 return std::any_of(m_strings.begin(), m_strings.end(),
194 [&](
const QString &s) { return message.getCategories().contains(s); });
196 return std::all_of(m_strings.begin(), m_strings.end(),
197 [&](
const QString &s) { return message.getCategories().contains(s); });
213 if (!(checkInvariants() && other.checkInvariants()))
223 if (!other.m_severities.contains(m_severities))
228 if (m_strategy == other.m_strategy && m_strings == other.m_strings)
232 return m_severities.size() < other.m_severities.size();
256 if (m_strategy != Everything && other.m_strategy == Everything) {
return true; }
260 switch (other.m_strategy)
262 case AnyOf:
return other.m_strings.contains(getString());
263 case StartsWith:
return getString().startsWith(other.getPrefix());
264 case EndsWith:
return getString().endsWith(other.getSuffix());
265 case Contains:
return getString().contains(other.getSubstring());
270 switch (other.m_strategy)
272 case AnyOf:
return other.m_strings.contains(m_strings) && other.m_strings.size() > m_strings.size();
274 return std::all_of(m_strings.begin(), m_strings.end(),
275 [&](
const QString &s) { return s.startsWith(other.getPrefix()); });
277 return std::all_of(m_strings.begin(), m_strings.end(),
278 [&](
const QString &s) { return s.endsWith(other.getSuffix()); });
280 return std::all_of(m_strings.begin(), m_strings.end(),
281 [&](
const QString &s) { return s.contains(other.getSubstring()); });
286 switch (other.m_strategy)
288 case ExactMatch:
return m_strings.contains(other.getString());
289 case AnyOf:
return !(m_strings & other.m_strings).isEmpty();
290 case AllOf:
return m_strings.contains(other.m_strings) && m_strings.size() > other.m_strings.size();
292 return std::any_of(m_strings.begin(), m_strings.end(),
293 [&](
const QString &s) { return s.startsWith(other.getPrefix()); });
295 return std::any_of(m_strings.begin(), m_strings.end(),
296 [&](
const QString &s) { return s.endsWith(other.getSuffix()); });
298 return std::any_of(m_strings.begin(), m_strings.end(),
299 [&](
const QString &s) { return s.contains(other.getSubstring()); });
304 switch (other.m_strategy)
307 return getPrefix().startsWith(other.getPrefix()) && getPrefix().size() > other.getPrefix().size();
308 case Contains:
return getPrefix().contains(other.getSubstring());
313 switch (other.m_strategy)
316 return getSuffix().endsWith(other.getSuffix()) && getSuffix().size() > other.getSuffix().size();
317 case Contains:
return getSuffix().contains(other.getSubstring());
322 switch (other.m_strategy)
325 return getSubstring().contains(other.getSubstring()) &&
326 getSubstring().size() > other.getSubstring().size();
339 QString categories = m_strings.values().join(
"|");
342 case Everything: strategy =
"all";
break;
343 case ExactMatch: strategy =
"exact match:" + categories;
break;
344 case AnyOf: strategy =
"any of:" + categories;
break;
345 case AllOf: strategy =
"all of:" + categories;
break;
346 case StartsWith: strategy =
"starts with:" + categories;
break;
347 case EndsWith: strategy =
"ends with:" + categories;
break;
348 case Contains: strategy =
"contains:" + categories;
break;
349 case Nothing: strategy =
"none";
break;
350 default: strategy =
"<invalid>";
break;
358 quint8 severities = 0;
359 for (
auto s : m_severities) { severities |= (1 <<
static_cast<int>(s)); }
361 argument << severities << m_strategy << m_strings.values();
368 argument >> severities >> m_strategy >> strings;
369 m_strings = QSet<QString>(strings.begin(), strings.end());
371 m_severities.clear();
372 for (
int s : { 0, 1, 2, 3 })
380 quint8 severities = 0;
381 for (
auto s : m_severities) { severities |= (1 <<
static_cast<int>(s)); }
383 stream << severities << m_strategy << m_strings.values();
390 stream >> severities >> m_strategy >> strings;
391 m_strings = QSet<QString>(strings.begin(), strings.end());
393 m_severities.clear();
394 for (
int s : { 0, 1, 2, 3 })
static const QString & verification()
Verification.
static const QString & uncategorized()
Uncategorized.
static const QString & webservice()
Webservice.
static const QString & download()
Generic downloads.
static const QString & matching()
Matching.
static const QString & dbus()
DBus related.
static const QString & swiftDataTool()
swift data tool (aka mapping tool)
static const QString & services()
Core/base services such as caching etc.
static const QString & contextSlot()
Context slots.
static const QString & cmdLine()
Cmd.line parsing.
static const QString & interpolator()
Interpolator.
static const QString & json()
JSON and JSON conversions.
static const QString & worker()
Background task.
static const QString & wizard()
Wizard.
static const QString & vatsimSpecific()
VATSIM specific.
static const QString & guiComponent()
GUI components.
static const QString & mapping()
Mapping.
static const QString & context()
Contexts.
static const QString & modelLoader()
Model loader.
static const QString & modelSetCache()
Model set cache.
static const QString & modelCache()
Model cache.
static const QString & plugin()
Plugin.
static const QString & modelGui()
Model UI.
static const QString & cache()
Cache.
static const QString & settings()
Settings.
static const QString & network()
Network specific, but not necessarily one specific flight network.
static const QString & validation()
Validation.
static const QString & swiftCore()
swift core
static const QString & flightPlan()
Flight plan.
static const QString & driver()
Driver.
static const QString & startup()
Startup of application.
static const QString & fsd()
FSD specific.
static const QString & swiftDbWebservice()
Webservice with swift DB.
static const QString & dataInconsistency()
Data inconsistency.
static const QString & swiftPilotClient()
swift GUI
A log category is an arbitrary string tag which can be attached to log messages.
bool startsWith(const QString &prefix) const
Returns true if the category string starts with the given prefix.
bool endsWith(const QString &suffix) const
Returns true if the category string ends with the given suffix.
bool contains(const QString &substring) const
Returns true if the category string contains the given substring.
A sequence of log categories.
QStringList toQStringList() const
Convert each of the categories to a QString and return the result as a QStringList.
Value class for matching log messages based on their categories.
static QStringList humanReadableNamesFrom(const CStatusMessage &message)
Human readable categories of message.
bool match(const CStatusMessage &message) const
Returns true if the given message matches this pattern.
static QStringList humanOrTechnicalCategoriesFrom(const CStatusMessage &message)
Human or machine readable categories of message.
static const CLogPattern & fromHumanReadableName(const QString &name)
Return a predefined CLogPattern corresponding to the given human-readable name.
QString convertToQString(bool i18n=false) const
Cast as QString.
CLogPattern withSeverities(const QSet< CStatusMessage::StatusSeverity > &severities) const
Returns a CLogPattern which will match the same messages as this one, but only with some given severi...
static CLogPattern endsWith(const QString &suffix)
Returns a CLogPattern which will match any message with a category which ends with the given suffix.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CLogPattern allOf(const CLogCategoryList &categories)
Returns a CLogPattern which will match any message with all of the given categories.
static const QStringList & allHumanReadableNames()
Get a list of human-readable names of predefined log patterns.
void marshallToDbus(QDBusArgument &argument) const
Marshall without begin/endStructure, for when composed within another object.
static CLogPattern exactMatch(const CLogCategory &category)
Returns a CLogPattern which will match any message with the given category.
CLogPattern withSeverity(CStatusMessage::StatusSeverity severity) const
Returns a CLogPattern which will match the same messages as this one, but only with a given severity.
static CLogPattern startsWith(const QString &prefix)
Returns a CLogPattern which will match any message with a category which starts with the given prefix...
static CLogPattern contains(const QString &substring)
Returns a CLogPattern which will match any message with a category which contains the given substring...
static CLogPattern empty()
Returns a CLogPattern which will match any message without a category.
void marshalToDataStream(QDataStream &stream) const
Marshal a value to a QDataStream.
bool isProperSubsetOf(const CLogPattern &other) const
Returns true if this pattern is a proper subset of the other pattern.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
static CLogPattern anyOf(const CLogCategoryList &categories)
Returns a CLogPattern which will match any message with any of the given categories.
CLogPattern()
Default constructed CLogPattern will match any message.
CLogPattern withSeverityAtOrAbove(CStatusMessage::StatusSeverity minimumSeverity) const
Returns a CLogPattern which will match the same messages, but only with a severity at or above the gi...
bool containsBy(Predicate p) const
Return true if there is an element for which a given predicate returns true.
bool contains(const T &object) const
Return true if there is an element equal to given object. Uses the most efficient implementation avai...
size_type size() const
Returns number of elements in the sequence.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
constexpr static auto SeverityDebug
Status severities.
constexpr static auto SeverityError
Status severities.
StatusSeverity getSeverity() const
Message severity.
const CLogCategoryList & getCategories() const
Message categories.
constexpr static auto SeverityInfo
Status severities.
constexpr static auto SeverityWarning
Status severities.
static QString severitiesToString(const QSet< StatusSeverity > &severities)
Severity set as string.
QString toQString(bool i18n=false) const
Cast as QString.
Free functions in swift::misc.
StatusSeverity
Status severities.