-
Notifications
You must be signed in to change notification settings - Fork 5k
Error handling
Gabi Melman edited this page Aug 26, 2016
·
9 revisions
Spdlog will not throw exceptions while logging (since version 39cdd08).
It might throw during the construction logger or sink, because it is considered fatal.
If an error happens during logging, the library will print an error message to stderr. To avoid flooding the screen with error messages, the rate is limited per logger to 1 message/minute.
This behaviour can be changed by calling spdlog::set_error_handler(new_handler_fun) or logger->set_error_handler(new_handler_fun):
Globally change the error handler:
spdlog::set_error_handler([](const std::string& msg) {
std::cerr << "my err handler: " << msg << std::endl;
});For a specific logger:
critical_logger->set_error_handler([](const std::string& msg) {
throw std::runtime_error(msg);
});
©gabime 2023-2024 spdlog. All Rights Reserved.