refs #642, fixed setup loading, in same step refs #636 clear cache

* changed signals in setup reader
* explicit mode is default
* detailed information what is loaded
* new log pattern
* allow to add message list to log component
* allow to clear cache by cmd line arg
* consolidated cmd names
This commit is contained in:
Klaus Basan
2016-04-14 02:27:23 +02:00
parent bd9de9308c
commit d0daad7d34
17 changed files with 372 additions and 159 deletions

View File

@@ -106,6 +106,13 @@ namespace BlackMisc
return cat;
}
//! Startup of application
static const CLogCategory &startup()
{
static const CLogCategory cat { "swift.startup" };
return cat;
}
//! Webservice with swift DB
static const CLogCategory &swiftDbWebservice()
{
@@ -135,6 +142,7 @@ namespace BlackMisc
matching(),
swiftDbWebservice(),
services(),
startup(),
validation(),
vatsimSpecific(),
verification(),

View File

@@ -28,6 +28,7 @@ namespace BlackMisc
{ "downloading data", exactMatch(CLogCategory::download()) },
{ "VASTIM specific", exactMatch(CLogCategory::vatsimSpecific()) },
{ "webservice related", exactMatch(CLogCategory::webservice()) },
{ "startup phase", exactMatch(CLogCategory::startup()) },
{ "swift DB webservice related", exactMatch(CLogCategory::swiftDbWebservice()) },
{ "Qt library", startsWith("qt.") },
{ "uncategorized (other)", empty() }

View File

@@ -197,6 +197,13 @@ namespace BlackMisc
return c.isEmpty() ? this->getCategoriesAsString() : c;
}
bool CStatusMessage::clipSeverity(CStatusMessage::StatusSeverity severity)
{
if (this->getSeverity() <= severity) { return false; }
this->setSeverity(severity);
return true;
}
bool CStatusMessage::isSuccess() const
{
return !isFailure();

View File

@@ -205,6 +205,9 @@ namespace BlackMisc
//! Message severity
StatusSeverity getSeverity() const { return this->m_severity; }
//! Clip/reduce severity if higher (more critical)
bool clipSeverity(StatusSeverity severity);
//! Info or debug, no warning or error
bool isSeverityInfoOrLess() const { return this->m_severity == SeverityInfo || this->m_severity == SeverityDebug; }

View File

@@ -17,6 +17,11 @@ namespace BlackMisc
CSequence<CStatusMessage>(other)
{ }
CStatusMessageList::CStatusMessageList(const CStatusMessage &statusMessage)
{
this->push_back(statusMessage);
}
CStatusMessageList CStatusMessageList::findByCategory(const CLogCategory &category) const
{
return this->findBy([ & ](const CStatusMessage & msg) { return msg.getCategories().contains(category); });
@@ -43,6 +48,29 @@ namespace BlackMisc
([ = ](const CStatusMessage & m) { return m.getSeverity() == CStatusMessage::SeverityWarning || m.getSeverity() == CStatusMessage::SeverityError; });
}
bool CStatusMessageList::isSuccess() const
{
return !this->isFailure();
}
bool CStatusMessageList::isFailure() const
{
return this->contains(&CStatusMessage::isFailure, true);
}
CStatusMessageList CStatusMessageList::getErrorMessages() const
{
return findBySeverity(SeverityError);
}
CStatusMessageList CStatusMessageList::getWarningAndErrorMessages() const
{
return this->findBy([ & ](const CStatusMessage & msg)
{
return msg.getSeverity() >= CStatusMessage::SeverityWarning;
});
}
void CStatusMessageList::addCategory(const CLogCategory &category)
{
for (auto &msg : *this)
@@ -73,8 +101,16 @@ namespace BlackMisc
{
msg.setCategories(categories);
}
}
}
void CStatusMessageList::clipSeverity(CStatusMessage::StatusSeverity severity)
{
for (auto &msg : *this)
{
msg.clipSeverity(severity);
}
}
void CStatusMessageList::removeWarningsAndBelow()
{
if (this->isEmpty()) { return; }

View File

@@ -37,6 +37,9 @@ namespace BlackMisc
//! Construct from a base class object.
CStatusMessageList(const CSequence<CStatusMessage> &other);
//! Construct from single message
CStatusMessageList(const CStatusMessage &statusMessage);
//! Find by type
CStatusMessageList findByCategory(const CLogCategory &category) const;
@@ -52,6 +55,18 @@ namespace BlackMisc
//! Warning or error messages
bool hasWarningOrErrorMessages() const;
//! All messages are marked as success
bool isSuccess() const;
//! Any message is marked as failure
bool isFailure() const;
//! Get all error messages
CStatusMessageList getErrorMessages() const;
//! Get all warning and error messages
CStatusMessageList getWarningAndErrorMessages() const;
//! Add a category to all messages in the list
void addCategory(const CLogCategory &category);
@@ -64,6 +79,9 @@ namespace BlackMisc
//! Reset the categories of all messages in the list
void setCategories(const CLogCategoryList &categories);
//! And higher (more critical) severity will be clipped to given severity
void clipSeverity(CStatusMessage::StatusSeverity severity);
//! Remove warnings and below
void removeWarningsAndBelow();