mirror of
https://github.com/FairRootGroup/FairLogger.git
synced 2025-10-15 17:41:44 +00:00
Add getters for file & custom sink severity
This commit is contained in:
@@ -42,6 +42,10 @@ int main()
|
||||
uniform_int_distribution<> distrib(1, 65536);
|
||||
string name = Logger::InitFileSink(Severity::warn, string("test_log_" + to_string(distrib(gen))), true);
|
||||
|
||||
if (Logger::GetFileSeverity() != Severity::warn) {
|
||||
throw runtime_error(ToStr("File sink severity (", Logger::fSeverityNames.at(static_cast<int>(Logger::GetFileSeverity())), ") does not match the expected one (", Logger::fSeverityNames.at(static_cast<int>(Severity::warn)), ")"));
|
||||
}
|
||||
|
||||
CheckOutput("^\\[FATAL] fatal\n$", [](){
|
||||
LOG(state) << "state";
|
||||
LOG(warn) << "warning";
|
||||
@@ -85,6 +89,20 @@ int main()
|
||||
}
|
||||
});
|
||||
|
||||
if (Logger::GetCustomSeverity("CustomSink") != Severity::warn) {
|
||||
throw runtime_error(ToStr("File sink severity (", Logger::fSeverityNames.at(static_cast<int>(Logger::GetCustomSeverity("CustomSink"))), ") does not match the expected one (", Logger::fSeverityNames.at(static_cast<int>(Severity::warn)), ")"));
|
||||
}
|
||||
|
||||
bool oorThrown = false;
|
||||
try {
|
||||
Logger::GetCustomSeverity("NonExistentSink");
|
||||
} catch (const out_of_range& oor) {
|
||||
oorThrown = true;
|
||||
}
|
||||
if (!oorThrown) {
|
||||
throw runtime_error("Did not detect a severity request from a non-existent sink");
|
||||
}
|
||||
|
||||
CheckOutput("^CustomSink warning\nCustomSink error\nCustomSink fatal\n\\[FATAL] fatal\n$", [](){
|
||||
LOG(state) << "state";
|
||||
LOG(warn) << "warning";
|
||||
|
Reference in New Issue
Block a user