Skip to content

Append::flush is fallible #112

@tisonkun

Description

@tisonkun

So far, we use eprintln! to handle some fallible flush in place. We should change the signature of Append::flush and handle all the error in:

impl log::Log for Logger {
    fn enabled(&self, metadata: &Metadata) -> bool {
        self.dispatches
            .iter()
            .any(|dispatch| dispatch.enabled(metadata))
    }

    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 {
            dispatch.flush(); <- use a similar pattern to `log`
        }
    }
}

Maybe add an ErrorSink trait for customizing error handling logics also.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions