-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why do you have to call flush all the time ? #4
Comments
Hey! Appreciate the feedback. Thanks for the enhancement suggestions, they all look interesting, and I would love to implement them some day, probably not any time soon tho because I am focused on something else right now. Feel free to open a pull request if you would want to implement them yourself tho.
Flush is pretty expensive, especially for files, I would imagine it's OK to have it flush for the asynchronous logger every time, perhaps I should add that feature. (atm it does flush on destruction, and when a file is closed/switched)
Logging is completely TS, however, changing logger properties (e.g pattern) from multiple threads isn't.
Confirmed on Windows and Linux, cannot say anything about Mac because I don't have one at home to test it on. |
Well I cannot imagine any logger that would not write to file... eventually ? Calling yourself when to write to file is a bit strange. Also when we say "async" it means immediately, so it would need to write immediately to file ? Or maybe I got it wrong how to use your logger ? Nevertheless, if you use this for example in 50 threads at once and you have important logs, calling flush from each of them would cause issues ?
That sounds great to me!
Great stuff! S**** Apple :) |
Yeah it does write eventually like I said, upon destruction or switching files.
"async" means asynchronous, not immediate. but I do agree that the async version should flush by itself every time.
No, it shouldn't, it would simply call flush 50 times atomically. |
Great stuff then, for now I will use it as is until you can update it for a bit 👍 |
I got a (dumb) question, but quite crucial... how would one use this across the whole application ? Say in threads, different classes etc ? Would this work ?
Then just add in each class:
Is this safe/ok ? |
Yeah, this should work. You could also make it static or something. Also, there is a typedef |
Yeah well, my idea does not work and neither your bl::logger::ptr for some reason in another class. Weirdly, it was works in threads. This is most likely because the class I was trying to use it in, was later instantiated using std::make_shared. The solution for now was, to define bl::logger::ptr m_BLogger; in the main file, and then extern bl::logger::ptr m_BLogger; in the precompiled header :( |
First of all, great work! Second, why do I have to call flush to write to file ?
I`m testing this on Windows with the following code:
No matter what options you will use (even async) it will not write to file until you called flush();. The idea is to write to file whatever you output to console.
Is this expected ?
Further enhancements:
Also I have a couple of questions:
Thank you!
The text was updated successfully, but these errors were encountered: