Skip to main content

Logger

Struct Logger 

Source
pub struct Logger { /* private fields */ }
Available on crate feature std only.
Expand description

The configured log pipeline.

Implementations§

Source§

impl Logger

Source

pub fn builder() -> LoggerBuilder

Start configuring a logger.

Source

pub fn threshold_for(&self, target: &str) -> Level

The configured filter threshold for target.

Source

pub fn enabled(&self, target: &str, level: Level) -> bool

Returns true if a record with this severity and target would pass the filter. Use in hot paths to skip field construction before Self::log.

Source

pub fn min_level(&self) -> Level

The lowest severity the filter admits anywhere. Useful for short-circuiting macros at the call site.

Source

pub fn log(&self, level: Level, message: &str, fields: &[Field<'_>])

Emit a record using the empty string as the target. The simplest entry point; macros prefer Self::try_emit so they can attach source location.

Source

pub fn try_log( &self, level: Level, target: &str, message: &str, fields: &[Field<'_>], ) -> Result<()>

Emit a record at level with explicit target.

Sink errors are passed to the configured error handler (if any) and then returned. Use Self::log for fire-and-forget calls.

§Errors

Returns the first sink error; remaining sinks still receive the record so a transient failure on one destination does not starve the others.

Source

pub fn try_emit( &self, metadata: Metadata<'_>, message: &str, fields: &[Field<'_>], ) -> Result<()>

Lowest-level emission entry point. Accepts a fully-constructed Metadata so the caller (typically a macro) can attach source location.

The logger augments the metadata with a timestamp (if enabled) before dispatch. Filtering uses metadata.target and metadata.level.

§Errors

Returns the first sink error encountered. Other sinks are still attempted; see the type-level docs on dispatch semantics.

Source

pub fn flush(&self) -> Result<()>

Flush every configured sink. Use during graceful shutdown to drain buffered output.

§Errors

Returns the first flush error. Other sinks are still flushed.

Source

pub fn sink_count(&self) -> usize

Number of installed sinks. Useful for assertions in tests and for logging the logger’s own configuration.

Trait Implementations§

Source§

impl Clone for Logger

Source§

fn clone(&self) -> Logger

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 Debug for Logger

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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.