Comments (7)
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.
from async.
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.
from async.
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 is_empty()
: https://docs.rs/crossbeam-channel/latest/crossbeam_channel/struct.Sender.html#method.is_empty
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 is_empty() == true
with some polling interval). If it's a trait, add a default impl that just return a custom IO error "unsupported" for backward compat.
@Techcable for awareness.
from async.
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.
from async.
@dpc: Some question for undestanding the problem better: Do you think it makes sense to make a new trait Flushable
which a Drain instance can have where it would implement flush
in lib slog/lib.rs
.
And then make an implementation for Async
as you suggested =).
Thanks alot
from async.
Ah maybe its better to add this functionality to the Drain
with a default implementation?
from async.
Most ecosystem expects Drain
already, so it would have be a new method on an existing trait with an default impl that does something reasonable (like signals lack of support for flushing).
from async.
Related Issues (13)
- Dropping AsyncCore in the logger thread will cause panic HOT 5
- A future-based drain for the asynchronous future HOT 7
- Release new minor version HOT 1
- Replace crossbeam with std::sync::mpsc HOT 5
- slog-rsync doesn't compile with rust-nightly-2017-07-08 or rust-nightly-2017-07-09 HOT 4
- Performance regression between 2.3.0 and 2.5.0 - crossbeam-channel? HOT 9
- crates-io release? HOT 4
- slog-async: even with increased chan_size, "logger dropped messages due to channel overflow" HOT 2
- missing tag for v2.5.0 HOT 1
- panic with message '`ToSendSerializer` can't fail: Other'
- Solution for using in DLL
- slog-async: logger dropped messages due to channel overflow HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async.