25 lines
512 B
Rust
25 lines
512 B
Rust
pub trait LoggableError {
|
|
fn info_failed(self, msg: &str);
|
|
fn warn_failed(self, msg: &str);
|
|
fn err_failed(self, msg: &str);
|
|
}
|
|
|
|
impl<T, E: std::error::Error> LoggableError for Result<T, E> {
|
|
fn info_failed(self, msg: &str) {
|
|
if let Err(e) = self {
|
|
tracing::info!("{} : {}", msg, e);
|
|
}
|
|
}
|
|
|
|
fn warn_failed(self, msg: &str) {
|
|
if let Err(e) = self {
|
|
tracing::warn!("{} : {}", msg, e);
|
|
}
|
|
}
|
|
|
|
fn err_failed(self, msg: &str) {
|
|
if let Err(e) = self {
|
|
tracing::error!("{} : {}", msg, e);
|
|
}
|
|
}
|
|
}
|