With thread-pool of 1 thread, can I use _st
-sinks?
#1852
-
I have a multi-threaded application (Linux), some of it's threads have real-time priority (RT Kernel patch in place). I intend to
I have not checked the implementation details of SpdLog, but from a logical standpoint, I would have assumed that with a thread pool of 1 thread, the sink(s) will be accessed by that single thread only and therefore I could use the "single threaded sinks" ( Is my thinking correct? Or more broadly: Is my approach of using single-threaded-thread-pool to decouple the "application path" from the "logging path" ok? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
Right. As long as all loggers with the shared sinks use async logging.
Sounds right. Please see full queue policies to choose how to handle cases when the queue gets full. |
Beta Was this translation helpful? Give feedback.
-
Strange.. I don't understand how “_st/_mt” sinks can affect to the lifetime of the thread pool. How do you create the thread pool and loggers? can you share ? |
Beta Was this translation helpful? Give feedback.
-
Does it happen in some static init section before main? Or perhaps the CreateLogger() calls? this might cause using different thread pools due to the undefined init order of statics. Also, spdlog’s stdout sinks all share same global console mutex, so there a chance that there is a use of stdout logger elsewhere(e.g. call to spdlog::info(..))? btw the |
Beta Was this translation helpful? Give feedback.
-
Right, set_pattern propagates to the sink, so no wonder it crashes if called from 2 threads(and the sink is _st). You can call Would be good if you fix and try again to make sure the test indeed passes as expected.
It has no effect since the loggers are not registered. |
Beta Was this translation helpful? Give feedback.
-
Yes. seems normal. one for the thread pool and one for the flush_every() thread. Should not cause crash. |
Beta Was this translation helpful? Give feedback.
-
ok..feel free to update on any news. |
Beta Was this translation helpful? Give feedback.
Right. As long as all loggers with the shared sinks use async logging.
Sounds right. Please see full queue policies to choose how to handle cases when the queue gets full.