Turning off backend thread #645
Replies: 2 comments
-
Hey, unfortunately not. Currently the library is designed with focus on asynchronous logging and deferred formatting. Much of its implementation is based on multi-threaded use. While I've been considering adding synchronous logging as a feature, it would require significant changes. In fact, achieving good efficiency in synchronous mode would likely involve creating a nearly separate implementation, making it feel like a different library altogether. That said, there are some workarounds you can try depending on your needs: If you want to minimize resource usage in simulation:
If you want to simulate synchronous logging:You can force logs to flush immediately after each log statement. This blocks the caller's thread until the log is fully processed, effectively mimicking synchronous behaviour. However, note that in this case, setting a high sleep duration for the backend thread will slow things down, so avoid combining the two. You can enable this behaviour only during simulation builds. For example, set the QUILL_IMMEDIATE_FLUSH to |
Beta Was this translation helpful? Give feedback.
-
Got it. I tried increasing sleep duration and I think that's solving my needs. The default setting is actually very fast! Thanks so much, |
Beta Was this translation helpful? Give feedback.
-
Hi. I'm using quill and it's working very well.
I use quill for both simulation and production of my system. In production, it's great to have async logging. But in simulation I was thinking it would be better to not spawn a separate thread for quill. Is it possible to not spawn a new backend thread and do the logging synchronously in a synchronous mode?
Thanks,
James
Beta Was this translation helpful? Give feedback.
All reactions