-
Notifications
You must be signed in to change notification settings - Fork 24
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
question: How to flush on a async logger? #35
Comments
Can't really flush an async logger, as it can't not control the receiver on the other side of a channel. The closest thing we could have is maybe waiting for the channel to empty. But I'm not sure if we should. Generally displaying password prompts via logging is not a good idea. One should be using stderr for that, or some completely different things altogether. |
Jeah sure. I guessed that its kind of tricky, waiting till the channel has emptied is close, but probably still no guaranteed that the underlaying drains have been flushed... only the channel is empty... Thanks for the response. I find another solution. |
Ah. I'm silly. You are logging with slog-async, and then you might want to display prompt etc. on stderr . It seems like a legitimate use case... Under the hood we are using Line 336 in c2040ac
crossbeam-channel .
It does support So i guess we (I mean... you, if you care enough to submit a PR :D ) could add a new method to the trait / API that would attempt to "flush" (e.g. wait until @Techcable for awareness. |
Yes, you understood that correctly. Yes, sounds interesting to have a look at over the weekend. Thanks for pointing into the directions! If there are more thoughts let me know. |
@dpc: Some question for undestanding the problem better: Do you think it makes sense to make a new trait Thanks alot |
Ah maybe its better to add this functionality to the |
Most ecosystem expects |
How can I instruct the
log = create_logger_cli(false)
to be flushed manually (I have a password prompt on stdout which should first flush the whole log such that the prompt is at the right place)Basically
log.flush()
which would block until all records have been processed by the thread? Is there another better method?The text was updated successfully, but these errors were encountered: