mycelium_trace::writer

Trait MakeWriterExt

Source
pub trait MakeWriterExt<'a>: MakeWriter<'a> {
    // Provided methods
    fn with_max_level(self, level: Level) -> WithMaxLevel<Self>
       where Self: Sized { ... }
    fn with_min_level(self, level: Level) -> WithMinLevel<Self>
       where Self: Sized { ... }
    fn with_filter<F>(self, filter: F) -> WithFilter<Self, F>
       where Self: Sized,
             F: Fn(&Metadata<'_>) -> bool { ... }
    fn and<B>(self, other: B) -> Tee<Self, B>
       where Self: Sized,
             B: MakeWriter<'a> + Sized { ... }
    fn or_else<B>(self, other: B) -> OrElse<Self, B>
       where Self: MakeWriter<'a> + Sized,
             B: MakeWriter<'a> + Sized { ... }
    fn with_line_len(self, len: usize) -> WithLineLen<Self>
       where Self: MakeWriter<'a> + Sized { ... }
}
Expand description

Extension trait adding combinators for working with types implementing MakeWriter.

This is not intended to be implemented directly for user-defined MakeWriters; instead, it should be imported when the desired methods are used.

Provided Methods§

Source

fn with_max_level(self, level: Level) -> WithMaxLevel<Self>
where Self: Sized,

Wraps self and returns a MakeWriter that will only write output for events at or below the provided verbosity Level. For instance, Level::TRACE is considered to be _more verbosethanLevel::INFO`.

Events whose level is more verbose than level will be ignored, and no output will be written.

Source

fn with_min_level(self, level: Level) -> WithMinLevel<Self>
where Self: Sized,

Wraps self and returns a MakeWriter that will only write output for events at or above the provided verbosity Level.

Events whose level is less verbose than level will be ignored, and no output will be written.

Source

fn with_filter<F>(self, filter: F) -> WithFilter<Self, F>
where Self: Sized, F: Fn(&Metadata<'_>) -> bool,

Wraps self with a predicate that takes a span or event’s Metadata and returns a bool. The returned MakeWriter’s MakeWriter::make_writer_for method will check the predicate to determine if a writer should be produced for a given span or event.

If the predicate returns false, the wrapped MakeWriter’s make_writer_for will return None. Otherwise, it calls the wrapped MakeWriter’s make_writer_for method, and returns the produced writer.

This can be used to filter an output based on arbitrary Metadata parameters.

Source

fn and<B>(self, other: B) -> Tee<Self, B>
where Self: Sized, B: MakeWriter<'a> + Sized,

Combines self with another type implementing MakeWriter, returning a new MakeWriter that produces writers that write to both outputs.

If writing to either writer returns an error, the returned writer will return that error. However, both writers will still be written to before the error is returned, so it is possible for one writer to fail while the other is written to successfully.

Source

fn or_else<B>(self, other: B) -> OrElse<Self, B>
where Self: MakeWriter<'a> + Sized, B: MakeWriter<'a> + Sized,

Combines self with another type implementing MakeWriter, returning a new MakeWriter that calls other’s make_writer if self’s make_writer returns None.

Source

fn with_line_len(self, len: usize) -> WithLineLen<Self>
where Self: MakeWriter<'a> + Sized,

Implementors§

Source§

impl<'a, M> MakeWriterExt<'a> for M
where M: MakeWriter<'a>,