tagparser/diagnostics.cpp

44 lines
823 B
C++
Raw Normal View History

#include "./diagnostics.h"
using namespace std;
namespace TagParser {
const char *diagLevelName(DiagLevel diagLevel)
{
2018-03-07 01:17:50 +01:00
switch (diagLevel) {
case DiagLevel::Information:
return "information";
case DiagLevel::Warning:
return "warning";
case DiagLevel::Critical:
return "critical";
case DiagLevel::None:
default:
return "";
}
}
bool Diagnostics::has(DiagLevel level) const
{
for (const auto &msg : *this) {
if (msg.level() >= level) {
return true;
}
}
return false;
}
DiagLevel Diagnostics::level() const
{
auto level = DiagLevel::None;
for (const auto &msg : *this) {
if ((level |= msg.level()) >= worstDiagLevel) {
return level;
}
}
return level;
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser