ParallelLogger

Struct ParallelLogger 

Source
pub struct ParallelLogger { /* private fields */ }
Expand description

A log::Log implementation that executes all logging in parallel.
Simply pass the actual loggers in the call to ParallelLogger::init.

Implementations§

Source§

impl ParallelLogger

Source

pub fn init( log_level: LevelFilter, mode: ParallelMode, actual_loggers: Vec<Box<dyn Log>>, ) -> ShutdownHandle

Initializes the ParallelLogger.

This function sets up a new ParallelLogger with the specified log level, the parallel execution mode and the actual loggers. Depending on the ParallelMode setting, either one or more threads will be created to process the actual loggers. The ParallelLogger is then set as the global logger for the log crate.

§Arguments
  • log_level - The maximum log level that the logger will handle. Log messages with a level higher than this will be ignored. This will also apply to the actual loggers even though those might have a higher log level set in their configs.
  • mode - The parallel execution mode that the ParallelLogger will use.
  • actual_loggers - The actual loggers that the ParallelLogger will forward log messages to.
§Returns

A ShutdownHandle that can be used to shut down the ParallelLogger and possibly flush the remaining messages in the queue.

§Panics
  • if another logger was already set for the log crate
  • if no actual logger was provided
  • if a thread could not be created

Trait Implementations§

Source§

impl Debug for ParallelLogger

Source§

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

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

impl Log for ParallelLogger

Source§

fn log(&self, record: &Record<'_>)

Forwards the log call to the actual loggers

Source§

fn flush(&self)

Forwards the flush call to the actual loggers

Source§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. 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> 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.