#error-logging #error #logging #error-handle

log-error

A small crate to log the error result easily

2 releases

0.1.1 Mar 6, 2023
0.1.0 Jun 23, 2022

#59 in #error-logging

Download history 22/week @ 2024-07-29 8/week @ 2024-08-05 11/week @ 2024-08-12 7/week @ 2024-08-19 60/week @ 2024-08-26 25/week @ 2024-09-02 38/week @ 2024-09-09 19/week @ 2024-09-16 57/week @ 2024-09-23 21/week @ 2024-09-30 19/week @ 2024-10-07 18/week @ 2024-10-14 6/week @ 2024-10-21 45/week @ 2024-10-28 29/week @ 2024-11-04 14/week @ 2024-11-11

96 downloads per month
Used in 2 crates

MIT license

6KB
92 lines

log-error

A small crate to log the error result easily

Sometimes we just want to record the error result, rather than return it to upper caller or unwrap the result with a panic, this crate will help you do it in relaxed

Example

use log_error::*;
use std::io::Error;

fn main() {
    simple_logger::SimpleLogger::new().env().init().unwrap();

    if let Some(_file) = std::fs::read("").log_warn("optional file") {
        // do something
    }

    // detailed error message
    do_something().log_error_detail("do_something");
}

fn do_something() -> Result<(), Error> {
    // ...
    Err(Error::last_os_error())
}

Dependencies

~87KB