Page:
Thread Safety
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
3
Thread Safety
Gabi Melman edited this page 2025-04-01 08:39:00 +03:00
Table of contents
Non thread safe functions
The following functions should not be called concurrently from multiple threads on the same logger object:
set_error_handler(log_err_handler);logger::sinks()- returns a reference to a non thread safe vector, so don't modify it concurrently (e.g.logger->sinks().push_back(new_sink);)
Note: This restriction applies to all kind of loggers ("_mt" or "_st").
Loggers
To create thread safe loggers, use the _mt factory functions.
For example:
auto logger = spdlog::basic_logger_mt(...);
To create single threaded loggers, use the _st factory functions.
For example:
auto logger = spdlog::basic_logger_st(...);
Sinks
- Thread safe sinks: sinks ending with
_mt(e.gdaily_file_sink_mt) - Non thread safe sinks: sinks ending with
_st(e.gdaily_file_sink_st)
©gabime 2023-2024 spdlog. All Rights Reserved.