mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +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;
|
return cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Downloading
|
//! Generic downloads
|
||||||
static const CLogCategory &download()
|
static const CLogCategory &download()
|
||||||
{
|
{
|
||||||
static const CLogCategory cat { "swift.download" };
|
static const CLogCategory cat { "swift.download" };
|
||||||
return cat;
|
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
|
//! All predefined special categories
|
||||||
//! \note Human readable patterns are defined in CLogPattern::allHumanReadablePatterns
|
//! \note Human readable patterns are defined in CLogPattern::allHumanReadablePatterns
|
||||||
static const QList<CLogCategory> &allSpecialCategories()
|
static const QList<CLogCategory> &allSpecialCategories()
|
||||||
@@ -89,7 +103,9 @@ namespace BlackMisc
|
|||||||
context(),
|
context(),
|
||||||
contextSlot(),
|
contextSlot(),
|
||||||
guiComponent(),
|
guiComponent(),
|
||||||
download()
|
download(),
|
||||||
|
webservice(),
|
||||||
|
swiftDbWebservice(),
|
||||||
};
|
};
|
||||||
return cats;
|
return cats;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ namespace BlackMisc
|
|||||||
{ "swift contexts", exactMatch(CLogCategory::context()) },
|
{ "swift contexts", exactMatch(CLogCategory::context()) },
|
||||||
{ "swift context slots", exactMatch(CLogCategory::contextSlot()) },
|
{ "swift context slots", exactMatch(CLogCategory::contextSlot()) },
|
||||||
{ "swift GUI", exactMatch(CLogCategory::guiComponent()) },
|
{ "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.") },
|
{ "Qt library", startsWith("qt.") },
|
||||||
{ "uncategorized (other)", empty() }
|
{ "uncategorized (other)", empty() }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -187,15 +187,13 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CStatusMessage CStatusMessage::fromDatabaseJson(const QJsonObject &json)
|
CStatusMessage CStatusMessage::fromDatabaseJson(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
CLogCategory cat("swift.db");
|
|
||||||
QString msgText(json.value("text").toString());
|
QString msgText(json.value("text").toString());
|
||||||
QString severityText(json.value("severity").toString());
|
QString severityText(json.value("severity").toString());
|
||||||
QString typeText(json.value("type").toString());
|
QString typeText(json.value("type").toString());
|
||||||
StatusSeverity severity = stringToSeverity(severityText);
|
StatusSeverity severity = stringToSeverity(severityText);
|
||||||
|
|
||||||
typeText = "swift.db.type." + typeText.toLower().remove(' ');
|
typeText = "swift.db.type." + typeText.toLower().remove(' ');
|
||||||
|
CStatusMessage m({ CLogCategory::swiftDbWebservice(), CLogCategory(typeText)}, severity, msgText);
|
||||||
CStatusMessage m({ cat, CLogCategory(typeText)}, severity, msgText);
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,21 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
msg.setCategories(categories);
|
msg.setCategories(categories);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStatusMessageList::removeWarningsAndBelow()
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return; }
|
||||||
|
this->removeIf(&CStatusMessage::getSeverity, CStatusMessage::SeverityWarning);
|
||||||
|
this->removeInfoAndBelow();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 CStatusMessageList::worstSeverity() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ namespace BlackMisc
|
|||||||
//! Reset the categories of all messages in the list
|
//! Reset the categories of all messages in the list
|
||||||
void setCategories(const CLogCategoryList &categories);
|
void setCategories(const CLogCategoryList &categories);
|
||||||
|
|
||||||
|
//! Remove warnings and below
|
||||||
|
void removeWarningsAndBelow();
|
||||||
|
|
||||||
|
//! Remove info and below
|
||||||
|
void removeInfoAndBelow();
|
||||||
|
|
||||||
//! Find worst severity
|
//! Find worst severity
|
||||||
CStatusMessage::StatusSeverity worstSeverity() const;
|
CStatusMessage::StatusSeverity worstSeverity() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user