Skip to content

Create an asynchronous logger but only for some trace levels #2186

Answered by tt4g
skeleton18 asked this question in Q&A
Discussion options

You must be logged in to vote

There is no implementation that delays the output of a particular log level, but the OS buffers the output to console or file, and the output is delayed until the spdlog flush operation is invoked.

You can set the log level to force the output of buffered log messages with spdlog::flush_on() (or spdlog::logger::flush_on()).

See Wiki: https://github.com/gabime/spdlog/wiki/7.-Flush-policy

If you want to do queuing in your application instead of relying on OS buffering, you can create a custom sink (https://github.com/gabime/spdlog/wiki/4.-Sinks#implementing-your-own-sink).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@skeleton18
Comment options

Answer selected by skeleton18
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