mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #526, category/statusmessage
* new categories * utility functions in status message
This commit is contained in:
@@ -71,13 +71,27 @@ namespace BlackMisc
|
||||
return cat;
|
||||
}
|
||||
|
||||
//! Downloading
|
||||
//! Generic downloads
|
||||
static const CLogCategory &download()
|
||||
{
|
||||
static const CLogCategory cat { "swift.download" };
|
||||
return cat;
|
||||
}
|
||||
|
||||
//! Webservice
|
||||
static const CLogCategory &webservice()
|
||||
{
|
||||
static const CLogCategory cat { "swift.webservice" };
|
||||
return cat;
|
||||
}
|
||||
|
||||
//! Webservice with swift DB
|
||||
static const CLogCategory &swiftDbWebservice()
|
||||
{
|
||||
static const CLogCategory cat { "swift.db.webservice" };
|
||||
return cat;
|
||||
}
|
||||
|
||||
//! All predefined special categories
|
||||
//! \note Human readable patterns are defined in CLogPattern::allHumanReadablePatterns
|
||||
static const QList<CLogCategory> &allSpecialCategories()
|
||||
@@ -89,7 +103,9 @@ namespace BlackMisc
|
||||
context(),
|
||||
contextSlot(),
|
||||
guiComponent(),
|
||||
download()
|
||||
download(),
|
||||
webservice(),
|
||||
swiftDbWebservice(),
|
||||
};
|
||||
return cats;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ namespace BlackMisc
|
||||
{ "swift contexts", exactMatch(CLogCategory::context()) },
|
||||
{ "swift context slots", exactMatch(CLogCategory::contextSlot()) },
|
||||
{ "swift GUI", exactMatch(CLogCategory::guiComponent()) },
|
||||
{ "swift downloads", exactMatch(CLogCategory::download()) },
|
||||
{ "downloading data", exactMatch(CLogCategory::download()) },
|
||||
{ "webservice related", exactMatch(CLogCategory::webservice()) },
|
||||
{ "swift DB webservice related", exactMatch(CLogCategory::swiftDbWebservice()) },
|
||||
{ "Qt library", startsWith("qt.") },
|
||||
{ "uncategorized (other)", empty() }
|
||||
};
|
||||
|
||||
@@ -187,15 +187,13 @@ namespace BlackMisc
|
||||
|
||||
CStatusMessage CStatusMessage::fromDatabaseJson(const QJsonObject &json)
|
||||
{
|
||||
CLogCategory cat("swift.db");
|
||||
QString msgText(json.value("text").toString());
|
||||
QString severityText(json.value("severity").toString());
|
||||
QString typeText(json.value("type").toString());
|
||||
StatusSeverity severity = stringToSeverity(severityText);
|
||||
|
||||
typeText = "swift.db.type." + typeText.toLower().remove(' ');
|
||||
|
||||
CStatusMessage m({ cat, CLogCategory(typeText)}, severity, msgText);
|
||||
CStatusMessage m({ CLogCategory::swiftDbWebservice(), CLogCategory(typeText)}, severity, msgText);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,23 @@ namespace BlackMisc
|
||||
{
|
||||
msg.setCategories(categories);
|
||||
}
|
||||
}
|
||||
|
||||
void CStatusMessageList::removeWarningsAndBelow()
|
||||
{
|
||||
if (this->isEmpty()) { return; }
|
||||
this->removeIf(&CStatusMessage::getSeverity, CStatusMessage::SeverityWarning);
|
||||
this->removeInfoAndBelow();
|
||||
}
|
||||
|
||||
CStatusMessage::StatusSeverity CStatusMessageList::worstSeverity() const
|
||||
void CStatusMessageList::removeInfoAndBelow()
|
||||
{
|
||||
if (this->isEmpty()) { return; }
|
||||
this->removeIf(&CStatusMessage::getSeverity, CStatusMessage::SeverityDebug);
|
||||
this->removeIf(&CStatusMessage::getSeverity, CStatusMessage::SeverityInfo);
|
||||
}
|
||||
|
||||
CStatusMessage::StatusSeverity CStatusMessageList::worstSeverity() const
|
||||
{
|
||||
CStatusMessage::StatusSeverity s = CStatusMessage::SeverityDebug;
|
||||
for (const CStatusMessage &msg : *this)
|
||||
|
||||
@@ -64,6 +64,12 @@ namespace BlackMisc
|
||||
//! Reset the categories of all messages in the list
|
||||
void setCategories(const CLogCategoryList &categories);
|
||||
|
||||
//! Remove warnings and below
|
||||
void removeWarningsAndBelow();
|
||||
|
||||
//! Remove info and below
|
||||
void removeInfoAndBelow();
|
||||
|
||||
//! Find worst severity
|
||||
CStatusMessage::StatusSeverity worstSeverity() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user