Skip to main content

LoggingLayer

Struct LoggingLayer 

Source
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 started log 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 ./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::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

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<I: Copy> Copy for LoggingLayer<I>

Source§

impl<I: Debug> Debug for LoggingLayer<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LoggingLayer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<I: LoggingInterceptor> Layer for LoggingLayer<I>

Source§

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

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.