Skip to content
Discussion options

You must be logged in to vote

Ah, I finally understand.
So you have one multi-threaded application with the terminal running in a dedicated thread (and spdlog in a another thread).
Sorry it took me so long to understand.

Then use the mutex that spdlog uses internally to protect access to stdout.
You can access it using spdlog::details::console_mutex::mutex():

struct console_mutex {
using mutex_t = std::mutex;
static mutex_t &mutex() {
static mutex_t s_mutex;
return s_mutex;
}
};

using stdout_sink_mt = stdout_sink<detai…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@officer-tuba
Comment options

@tt4g
Comment options

@officer-tuba
Comment options

@tt4g
Comment options

Answer selected by officer-tuba
@officer-tuba
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants