Throw if removing non-existing sink or adding existing

This commit is contained in:
Alexey Rybalchenko 2020-07-09 14:01:44 +02:00
parent e9bd3f2b62
commit 1253bbbac8
2 changed files with 3 additions and 0 deletions

View File

@ -577,6 +577,7 @@ void Logger::AddCustomSink(const string& key, Severity severity, function<void(c
UpdateMinSeverity();
} else {
cout << "Logger::AddCustomSink: sink '" << key << "' already exists, will not add again. Remove first with Logger::RemoveCustomSink(const string& key)" << endl;
throw runtime_error("Adding a sink with a key that already exists. Remove first.");
}
}
@ -597,6 +598,7 @@ void Logger::RemoveCustomSink(const string& key)
UpdateMinSeverity();
} else {
cout << "Logger::RemoveCustomSink: sink '" << key << "' doesn't exists, will not remove." << endl;
throw runtime_error("Trying to remove a sink with a key that does not exist.");
}
}

View File

@ -39,6 +39,7 @@
#include <mutex>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <time.h> // time_t
#include <type_traits> // is_same