Skip to main content

Crate result_logger

Crate result_logger 

Source
Expand description

A utility crate for enhancing Result<T, E> with logging capabilities.

This crate provides the ResultLogging trait, which extends Result<T, E> with methods to log errors at different log levels using the log crate.

§Example Usage

use log::{LevelFilter, info};
use simple_logger::SimpleLogger;
use result_logger::ResultLogger;

fn example_function() -> Result<(), &'static str> {
    Err("Something went wrong!")
}

fn main() {
    SimpleLogger::new().init().unwrap();
    let _ = example_function().error(); // Logs the error message at the error level
}

Traits§

ResultLogger
A trait that provides logging capabilities for Result<T, E>.