pub struct LoggingLayer<I = DefaultLoggingInterceptor> { /* private fields */ }Expand description
LoggingLayer records every operation with
log.
§Logging
- OpenDAL emits structured logs.
- Every operation starts with a
startedlog entry. - Every operation ends with one of the following statuses:
succeeded: The operation succeeded but might have more work to perform.finished: The whole operation finished.failed: The operation returned an error.
- The default log level for expected errors is
Warn. - The default log level for unexpected errors is
Error.
§Examples
let _ = Operator::new(services::Memory::default())?
.layer(LoggingLayer::default());§Output
OpenDAL uses log internally.
To enable logging output, please set RUST_LOG:
RUST_LOG=debug ./appTo 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::ServiceInfo,
operation: raw::Operation,
context: &[(&str, &str)],
message: &str,
err: Option<&Error>,
) {
// log something
}
}
let _ = Operator::new(services::Memory::default())?
.layer(LoggingLayer::new(MyLoggingInterceptor));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: Clone> Clone for LoggingLayer<I>
impl<I: Clone> Clone for LoggingLayer<I>
Source§fn clone(&self) -> LoggingLayer<I>
fn clone(&self) -> LoggingLayer<I>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<I: Copy> Copy for LoggingLayer<I>
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<I: LoggingInterceptor> Layer for LoggingLayer<I>
impl<I: LoggingInterceptor> Layer for LoggingLayer<I>
Source§fn apply_service(&self, inner: Servicer) -> Servicer
fn apply_service(&self, inner: Servicer) -> Servicer
Intercept the operation service stack. Read more
Source§fn apply_context(
&self,
srv: Arc<dyn ServiceDyn>,
inner: OperationContext,
) -> OperationContext
fn apply_context( &self, srv: Arc<dyn ServiceDyn>, inner: OperationContext, ) -> OperationContext
Intercept the operation context (HTTP transport and executor). Read more
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> UnsafeUnpin for LoggingLayer<I>where
I: UnsafeUnpin,
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