pub trait ResultExt {
// Required methods
fn log_err(self, msg: impl Display) -> Self;
fn log_err_with<F>(self, f: F) -> Self
where F: FnOnce() -> String;
fn log_warn(self, msg: impl Display) -> Self;
fn log_warn_with<F>(self, f: F) -> Self
where F: FnOnce() -> String;
fn log_info(self, msg: impl Display) -> Self;
fn log_info_with<F>(self, f: F) -> Self
where F: FnOnce() -> String;
fn log_debug(self, msg: impl Display) -> Self;
fn log_debug_with<F>(self, f: F) -> Self
where F: FnOnce() -> String;
fn log_trace(self, msg: impl Display) -> Self;
fn log_trace_with<F>(self, f: F) -> Self
where F: FnOnce() -> String;
}Expand description
Extension trait for Result to log errors and warnings using the tracing
crate.
Required Methods§
Sourcefn log_err(self, msg: impl Display) -> Self
fn log_err(self, msg: impl Display) -> Self
Log errors at error level with a static message.
If you don’t care about the error message, call eg. log_err("").
Sourcefn log_err_with<F>(self, f: F) -> Self
fn log_err_with<F>(self, f: F) -> Self
Log errors at error level with a message generated by a closure.
Sourcefn log_warn(self, msg: impl Display) -> Self
fn log_warn(self, msg: impl Display) -> Self
Log errors at warning level with a static message.
If you don’t care about the error message, call eg. log_warn("").
Sourcefn log_warn_with<F>(self, f: F) -> Self
fn log_warn_with<F>(self, f: F) -> Self
Log errors at warning level with a message generated by a closure.
Sourcefn log_info(self, msg: impl Display) -> Self
fn log_info(self, msg: impl Display) -> Self
Log errors at informational level with a static message.
If you don’t care about the error message, call eg. log_warn("").
Sourcefn log_info_with<F>(self, f: F) -> Self
fn log_info_with<F>(self, f: F) -> Self
Log errors at informational level with a message generated by a closure.
Sourcefn log_debug(self, msg: impl Display) -> Self
fn log_debug(self, msg: impl Display) -> Self
Log errors at debug level with a static message.
If you don’t care about the error message, call eg. log_warn("").
Sourcefn log_debug_with<F>(self, f: F) -> Self
fn log_debug_with<F>(self, f: F) -> Self
Log errors at debug level with a message generated by a closure.
Sourcefn log_trace(self, msg: impl Display) -> Self
fn log_trace(self, msg: impl Display) -> Self
Log errors at trace level with a static message.
If you don’t care about the error message, call eg. log_warn("").
Sourcefn log_trace_with<F>(self, f: F) -> Self
fn log_trace_with<F>(self, f: F) -> Self
Log errors at trace level with a message generated by a closure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T, E> ResultExt for Result<T, E>where
E: Debug,
Available on crate feature tracing only.
impl<T, E> ResultExt for Result<T, E>where
E: Debug,
tracing only.