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::services;
use opendal::Operator;
use opendal::Scheme;
let _ = Operator::from_env::<services::Fs>()
.expect("must init")
.layer(LoggingLayer::default())
.finish();
Output
OpenDAL is using log
for logging internally.
To enable logging output, please set RUST_LOG
:
RUST_LOG=debug ./app
To config logging output, please refer to Configure Logging:
RUST_LOG="info,opendal::services=debug" ./app
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 moresource§impl Debug for LoggingLayer
impl Debug for LoggingLayer
source§impl Default for LoggingLayer
impl Default for LoggingLayer
source§impl<A: Accessor> Layer<A> for LoggingLayer
impl<A: Accessor> Layer<A> for LoggingLayer
§type LayeredAccessor = LoggingAccessor<A>
type LayeredAccessor = LoggingAccessor<A>
The layered accessor that return by this layer.
source§fn layer(&self, inner: A) -> Self::LayeredAccessor
fn layer(&self, inner: A) -> Self::LayeredAccessor
Intercept the operations on the underlying storage.