pub trait LogError<T>: Sized {
// Required methods
fn log_as(self, level: Level) -> Option<T>;
fn log_with_context_as<Ctx: Fn() -> String>(
self,
level: Level,
ctx: Ctx,
) -> Option<T>;
fn log_as_passthrough(self, level: Level) -> Self;
fn log_with_context_as_passthrough<Ctx: Fn() -> String>(
self,
level: Level,
ctx: Ctx,
) -> Self;
// Provided methods
fn log(self) -> Option<T> { ... }
fn log_context(self, ctx: &str) -> Option<T> { ... }
fn log_with_context<Ctx: Fn() -> String>(self, ctx: Ctx) -> Option<T> { ... }
fn log_context_as(self, level: Level, ctx: &str) -> Option<T> { ... }
fn log_passthrough(self) -> Self { ... }
fn log_context_passthrough(self, ctx: &str) -> Self { ... }
fn log_with_context_passthrough<Ctx: Fn() -> String>(self, ctx: Ctx) -> Self { ... }
fn log_context_as_passthrough(self, level: Level, ctx: &str) -> Self { ... }
}
Expand description
Enables logging of errors, to move forward without returning the error.
Required Methods§
Sourcefn log_as(self, level: Level) -> Option<T>
fn log_as(self, level: Level) -> Option<T>
Logs if there was an error and converts the result into an option
Sourcefn log_with_context_as<Ctx: Fn() -> String>(
self,
level: Level,
ctx: Ctx,
) -> Option<T>
fn log_with_context_as<Ctx: Fn() -> String>( self, level: Level, ctx: Ctx, ) -> Option<T>
Lazily logs if there was an error with a message at the provided log level, and converts the result into an option
Sourcefn log_as_passthrough(self, level: Level) -> Self
fn log_as_passthrough(self, level: Level) -> Self
Logs if there was an error and returns the result unchanged
Sourcefn log_with_context_as_passthrough<Ctx: Fn() -> String>(
self,
level: Level,
ctx: Ctx,
) -> Self
fn log_with_context_as_passthrough<Ctx: Fn() -> String>( self, level: Level, ctx: Ctx, ) -> Self
Lazily logs if there was an error with a message at the provided log level, and returns the result unchanged
Provided Methods§
Sourcefn log_context(self, ctx: &str) -> Option<T>
fn log_context(self, ctx: &str) -> Option<T>
Logs if there was an error with a message and converts the result into an option
Sourcefn log_with_context<Ctx: Fn() -> String>(self, ctx: Ctx) -> Option<T>
fn log_with_context<Ctx: Fn() -> String>(self, ctx: Ctx) -> Option<T>
Lazily logs if there was an error with a message and converts the result into an option
Sourcefn log_context_as(self, level: Level, ctx: &str) -> Option<T>
fn log_context_as(self, level: Level, ctx: &str) -> Option<T>
Logs if there was an error with a message at the provided log level, and converts the result into an option
Sourcefn log_passthrough(self) -> Self
fn log_passthrough(self) -> Self
Logs if there was an error and returns the result unchanged
Sourcefn log_context_passthrough(self, ctx: &str) -> Self
fn log_context_passthrough(self, ctx: &str) -> Self
Logs if there was an error with a message and returns the result unchanged
Sourcefn log_with_context_passthrough<Ctx: Fn() -> String>(self, ctx: Ctx) -> Self
fn log_with_context_passthrough<Ctx: Fn() -> String>(self, ctx: Ctx) -> Self
Lazily logs if there was an error with a message and returns the result unchanged
Sourcefn log_context_as_passthrough(self, level: Level, ctx: &str) -> Self
fn log_context_as_passthrough(self, level: Level, ctx: &str) -> Self
Logs if there was an error with a message at the provided log level, and returns the result unchanged
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.