Skip to main content

tuwunel_core/utils/result/
log_err.rs

1use std::fmt::Display;
2
3use tracing::Level;
4
5use super::Result;
6use crate::error;
7
8pub trait LogErr<T, E: Display> {
9	#[must_use]
10	fn err_log(self, level: Level) -> Self;
11
12	#[must_use]
13	fn log_err(self) -> Self
14	where
15		Self: Sized,
16	{
17		self.err_log(Level::ERROR)
18	}
19}
20
21impl<T, E: Display> LogErr<T, E> for Result<T, E> {
22	#[inline]
23	fn err_log(self, level: Level) -> Self {
24		self.inspect_err(|error| error::inspect_log_level(&error, level))
25	}
26}