odygrd / quill

Asynchronous Low Latency C++ Logging Library
MIT License
1.14k stars 130 forks source link

How to flush logs on every new line? #488

Closed asaff1 closed 1 week ago

asaff1 commented 2 weeks ago

Is it possible to set the logs to always flush when a new line (similar to Python logging behavior)? print on every logging statement. Without manually calling flush each time.

Also when debugging, it takes some time the logs to appear, so it is good to have it enabled then, since cout and the logs are not ordered.

odygrd commented 1 week ago

it is not possible at the moment but i am adding it as a new feature for the next release.

Since i do not want to add another if statement on the hot path and that is meant to be mainly for debugging purposes i am adding it as a preprocessor flag that has to be defined QUILL_IMMEDIATE_FLUSH (https://github.com/odygrd/quill/pull/487/commits/ff4b2082dad08850106d90fd5016823cf5eb60f6)

This means that to enable it you will have to recompile your project with the flag

odygrd commented 1 week ago

This is done in master branch, you can define QUILL_IMMEDIATE_FLUSH in the preprocessor to enable flushing on each log statement