mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #489 Predefined log patterns with human readable names.
This commit is contained in:
@@ -12,6 +12,35 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
const QHash<QString, CLogPattern> &CLogPattern::allHumanReadablePatterns()
|
||||
{
|
||||
static const QHash<QString, CLogPattern> patterns
|
||||
{
|
||||
{ "uncategorized (swift)", exactMatch(CLogCategory::uncategorized()) },
|
||||
{ "validation", exactMatch(CLogCategory::validation()) },
|
||||
{ "swift contexts", exactMatch(CLogCategory::context()) },
|
||||
{ "swift context slots", exactMatch(CLogCategory::contextSlot()) },
|
||||
{ "swift GUI", exactMatch(CLogCategory::guiComponent()) },
|
||||
{ "swift downloads", exactMatch(CLogCategory::download()) },
|
||||
{ "Qt library", startsWith("qt.") },
|
||||
{ "uncategorized (other)", empty() }
|
||||
};
|
||||
return patterns;
|
||||
}
|
||||
|
||||
const QStringList &CLogPattern::allHumanReadableNames()
|
||||
{
|
||||
static const QStringList names = allHumanReadablePatterns().keys();
|
||||
return names;
|
||||
}
|
||||
|
||||
const CLogPattern &CLogPattern::fromHumanReadableName(const QString &name)
|
||||
{
|
||||
static const CLogPattern empty {};
|
||||
auto it = allHumanReadablePatterns().find(name);
|
||||
return it == allHumanReadablePatterns().end() ? empty : *it;
|
||||
}
|
||||
|
||||
CLogPattern::CLogPattern(Strategy strategy, const QSet<QString> &strings)
|
||||
: m_strategy(strategy), m_strings(strings)
|
||||
{
|
||||
|
||||
@@ -34,6 +34,12 @@ namespace BlackMisc
|
||||
public Mixin::Icon<CLogPattern>
|
||||
{
|
||||
public:
|
||||
//! Get a list of human-readable names of predefined log patterns.
|
||||
static const QStringList &allHumanReadableNames();
|
||||
|
||||
//! Return a predefined CLogPattern corresponding to the given human-readable name.
|
||||
static const CLogPattern &fromHumanReadableName(const QString &name);
|
||||
|
||||
//! Default constructed CLogPattern will match any message.
|
||||
CLogPattern();
|
||||
|
||||
@@ -121,6 +127,8 @@ namespace BlackMisc
|
||||
const QString &getPrefix() const { Q_ASSERT(m_strategy == StartsWith && m_strings.size() == 1); return *m_strings.begin(); }
|
||||
const QString &getSuffix() const { Q_ASSERT(m_strategy == EndsWith && m_strings.size() == 1); return *m_strings.begin(); }
|
||||
const QString &getSubstring() const { Q_ASSERT(m_strategy == Contains && m_strings.size() == 1); return *m_strings.begin(); }
|
||||
|
||||
static const QHash<QString, CLogPattern> &allHumanReadablePatterns();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user