Struct opendal::layers::LoggingLayer
source · pub struct LoggingLayer { /* private fields */ }
Expand description
LoggingLayer will add logging for OpenDAL.
Logging
- OpenDAL will log in structural way.
- Every operation will start with a
started
log entry. - Every operation will finish with the following status:
finished
: the operation is successful.errored
: the operation returns an expected error likeNotFound
.failed
: the operation returns an unexpected error.
Todo
We should migrate to log’s kv api after it’s ready.
Tracking issue: https://github.com/rust-lang/log/issues/328
Examples
use anyhow::Result;
use opendal::layers::LoggingLayer;
use opendal::Operator;
use opendal::Scheme;
let _ = Operator::from_env(Scheme::Fs)
.expect("must init")
.layer(LoggingLayer::default());
Implementations§
source§impl LoggingLayer
impl LoggingLayer
sourcepub fn with_error_level(self, level: Option<Level>) -> Self
pub fn with_error_level(self, level: Option<Level>) -> Self
Setting the log level while expected error happened.
For example: accessor returns ObjectNotFound.
None
means disable the log for error.
sourcepub fn with_failure_level(self, level: Option<Level>) -> Self
pub fn with_failure_level(self, level: Option<Level>) -> Self
Setting the log level while unexpected failure happened.
For example: accessor returns Unexpected network error.
None
means disable the log for failure.
Trait Implementations§
source§impl Clone for LoggingLayer
impl Clone for LoggingLayer
source§fn clone(&self) -> LoggingLayer
fn clone(&self) -> LoggingLayer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more