pub struct LoggingLayer<I = DefaultLoggingInterceptor> { /* private fields */ }
Expand description
Add log for every operation.
§Logging
- OpenDAL will log in structural way.
- Every operation will start with a
started
log entry. - Every operation will finish with the following status:
succeeded
: the operation is successful, but might have more to take.finished
: the whole operation is finished.failed
: the operation returns an unexpected error.
- The default log level while expected error happened is
Warn
. - The default log level while unexpected failure happened is
Error
.
§Examples
let _ = Operator::new(services::Memory::default())?
.layer(LoggingLayer::default())
.finish();
Ok(())
§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
§Logging Interceptor
You can implement your own logging interceptor to customize the logging behavior.
#[derive(Debug, Clone)]
struct MyLoggingInterceptor;
impl LoggingInterceptor for MyLoggingInterceptor {
fn log(
&self,
info: &raw::AccessorInfo,
operation: raw::Operation,
context: &[(&str, &str)],
message: &str,
err: Option<&Error>,
) {
// log something
}
}
let _ = Operator::new(services::Memory::default())?
.layer(LoggingLayer::new(MyLoggingInterceptor))
.finish();
Ok(())
Implementations§
Source§impl LoggingLayer
impl LoggingLayer
Sourcepub fn new<I: LoggingInterceptor>(logger: I) -> LoggingLayer<I>
pub fn new<I: LoggingInterceptor>(logger: I) -> LoggingLayer<I>
Create the layer with specific logging interceptor.
Trait Implementations§
Source§impl<I: Debug> Debug for LoggingLayer<I>
impl<I: Debug> Debug for LoggingLayer<I>
Source§impl Default for LoggingLayer
impl Default for LoggingLayer
Source§impl<A: Access, I: LoggingInterceptor> Layer<A> for LoggingLayer<I>
impl<A: Access, I: LoggingInterceptor> Layer<A> for LoggingLayer<I>
Source§type LayeredAccess = LoggingAccessor<A, I>
type LayeredAccess = LoggingAccessor<A, I>
The layered accessor that returned by this layer.
Source§fn layer(&self, inner: A) -> Self::LayeredAccess
fn layer(&self, inner: A) -> Self::LayeredAccess
Intercept the operations on the underlying storage.
Auto Trait Implementations§
impl<I> Freeze for LoggingLayer<I>where
I: Freeze,
impl<I> RefUnwindSafe for LoggingLayer<I>where
I: RefUnwindSafe,
impl<I> Send for LoggingLayer<I>where
I: Send,
impl<I> Sync for LoggingLayer<I>where
I: Sync,
impl<I> Unpin for LoggingLayer<I>where
I: Unpin,
impl<I> UnwindSafe for LoggingLayer<I>where
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Decompress response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more