Struct LogfmtBuilder

Source
pub struct LogfmtBuilder<W: Write> { /* private fields */ }
Expand description

A constructor for a Logfmt drain.

Implementations§

Source§

impl<W: Write> LogfmtBuilder<W>

Source

pub fn build(self) -> Logfmt<W>

Constructs the drain.

Source

pub fn set_prefix( self, prefix: fn(&mut dyn Write, &Record<'_>) -> Result, ) -> Self

Set a function that prints a (not necessarily logfmt-formatted) prefix to the output stream.

Source

pub fn no_prefix(self) -> Self

Sets the logger up to print no prefix, effectively starting the line entirely logfmt field-formatted.

Source

pub fn redact(self, redact: fn(&Key) -> Redaction) -> Self

Sets a function that makes decisions on whether to log a field.

This function must return a Redaction result, which has two variants at the moment: Redact::Skip to not log the field, and Redact::Plain to log the field value in plain text.

Source

pub fn print_msg(self, print: bool) -> Self

Choose whether to print the log message.

The default prefix already prints it, so the default is to skip.

Source

pub fn print_level(self, print: bool) -> Self

Choose whether to print the log level.

The default prefix already prints it, so the default is to skip.

Source

pub fn print_tag(self, print: bool) -> Self

Choose whether to print the log level.

The default prefix already prints it, so the default is to skip.

Source

pub fn force_quotes(self) -> Self

Force quoting field values even if they don’t contain quotable characters.

Setting this option will surround values with quotes like foo="bar".

Auto Trait Implementations§

§

impl<W> Freeze for LogfmtBuilder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for LogfmtBuilder<W>
where W: RefUnwindSafe,

§

impl<W> Send for LogfmtBuilder<W>
where W: Send,

§

impl<W> Sync for LogfmtBuilder<W>
where W: Sync,

§

impl<W> Unpin for LogfmtBuilder<W>
where W: Unpin,

§

impl<W> UnwindSafe for LogfmtBuilder<W>
where W: 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> 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, 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.
Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,