Add getters for file & custom sink severity

This commit is contained in:
Alexey Rybalchenko
2020-07-13 11:24:11 +02:00
parent de1014dabb
commit 1cb941021c
3 changed files with 41 additions and 6 deletions

View File

@@ -350,14 +350,19 @@ void Logger::SetFileSeverity(const string& severityStr)
void Logger::SetCustomSeverity(const string& key, const Severity severity)
{
try {
#ifdef FAIR_MIN_SEVERITY
if (severity < Severity::FAIR_MIN_SEVERITY && severity != Severity::nolog) {
cout << "Requested severity is higher than the enabled compile-time FAIR_MIN_SEVERITY (" << fSeverityNames.at(static_cast<int>(Severity::FAIR_MIN_SEVERITY)) << "), ignoring" << endl;
return;
}
if (severity < Severity::FAIR_MIN_SEVERITY && severity != Severity::nolog) {
cout << "Requested severity is higher than the enabled compile-time FAIR_MIN_SEVERITY (" << fSeverityNames.at(static_cast<int>(Severity::FAIR_MIN_SEVERITY)) << "), ignoring" << endl;
return;
}
#endif
fCustomSinks.at(key).first = severity; // TODO: range checks
UpdateMinSeverity();
fCustomSinks.at(key).first = severity; // TODO: range checks
UpdateMinSeverity();
} catch (const out_of_range& oor) {
LOG(error) << "No custom sink with id '" << key << "' found";
throw;
}
}
void Logger::SetCustomSeverity(const string& key, const string& severityStr)
@@ -370,6 +375,16 @@ void Logger::SetCustomSeverity(const string& key, const string& severityStr)
}
}
Severity Logger::GetCustomSeverity(const std::string& key)
{
try {
return fCustomSinks.at(key).first;
} catch (const out_of_range& oor) {
LOG(error) << "No custom sink with id '" << key << "' found";
throw;
}
}
void Logger::CycleConsoleSeverityUp()
{
int current = static_cast<int>(fConsoleSeverity);