continuwuity/src/core/utils/result/log_err.rs
Jason Volk c769fcc347 move core result into core utils
Signed-off-by: Jason Volk <jason@zemos.net>
2024-10-26 18:50:29 -04:00

24 lines
446 B
Rust

use std::fmt::Display;
use tracing::Level;
use super::Result;
use crate::error;
pub trait LogErr<T, E: Display> {
#[must_use]
fn err_log(self, level: Level) -> Self;
#[must_use]
fn log_err(self) -> Self
where
Self: Sized,
{
self.err_log(Level::ERROR)
}
}
impl<T, E: Display> LogErr<T, E> for Result<T, E> {
#[inline]
fn err_log(self, level: Level) -> Self { self.inspect_err(|error| error::inspect_log_level(&error, level)) }
}