Page:
Error handling
Pages
3. Custom formatting)
Asynchronous logging
CMake
Creating loggers
Custom formatting
Default logger
Error handling
FAQ
Flush policy
Home
How to use spdlog in DLLs
Integrating into Eclipse IDE
Language bindings
Logger registry
Makefile Only
Note for adding sinks on the fly
Preventing child processes from inheriting open log files
Preventing undefined thread ids in child processes
QuickStart
Reference documentation using Doxygen
Setting up JSON logging with spdlog
Sinks
Thread Safety
Tweaking
Windows unicode filenames
No results
9
Error handling
RL-S edited this page 2021-11-12 20:26:19 +01:00
Spdlog will not throw exceptions while logging (since version 39cdd08).
It might throw during the construction of a 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);
});
The default error handler
_default_err_handler will use this to print error
fmt::print(stderr, "[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, name(), msg);
©gabime 2023-2024 spdlog. All Rights Reserved.