-
Notifications
You must be signed in to change notification settings - Fork 15
feat: blocking appender for rolling file and syslog #111
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
Conversation
Ok(()) | ||
} | ||
|
||
fn flush(&self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andylokandy maybe flush should return anyhow::Result<()>
and we handle error all at one level up:
fn log(&self, record: &Record) {
for dispatch in &self.dispatches {
if let Err(err) = dispatch.log(record) {
handle_error(record, err);
}
}
}
fn flush(&self) {
for dispatch in &self.dispatches {
if let Err(err) = dispatch.flush() {
handle_flush_error(err);
}
}
}
also maybe add a ErrorSink trait for custom error listener.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep the behavior in sync with non-blocking its variant. is the non blocking one return result on flush?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The non-blocking one do flush in the worker thread where the error is handled as eprintln!("failed to write log: {err}");
.
Signed-off-by: tison <[email protected]>
1e56fc8
to
570cf0b
Compare
Signed-off-by: tison <[email protected]>
570cf0b
to
bff61e0
Compare
I'm curious why |
|
Sound reasonable. I'll take some time to play with it. |
This closes #96