[][src]Struct poly_logger::PolyLogger

pub struct PolyLogger { /* fields omitted */ }

Implements a super-logger that can redirect to other loggers

This is useful if you want to log some messages to STDERR or STDOUT and some to File in perhaps a different format. When using PolyLogger, you create any number of child loggers and add them to the PolyLogger. Then you set the PolyLogger instance as the only one to be passed to the log system via init().

Example

Create a file logger with the default timestamp/message format, and also a raw logger for debug messages which gets sent to STDERR.

use log::{debug,info,LevelFilter};
use poly_logger::{FileLogger,StderrLogger,PolyLogger};

let mut stderr_log = StderrLogger::new(LevelFilter::Debug);
stderr_log.msg_format("{args}");

let mut file_log = FileLogger::new(LevelFilter::Info);
file_log.filename("./test.log");

let mut poly_log = PolyLogger::new();
poly_log.add(file_log.create()); // create() returns the GenLogger
poly_log.add(stderr_log);
poly_log.init();

info!("This goes to both loggers");
debug!("This only goes to stderr");

Implementations

impl PolyLogger[src]

pub fn new() -> Self[src]

Instantiate a new PolyLogger

pub fn init(self) -> Result<(), SetLoggerError>[src]

Initializes the log interface using this PolyLogger as a boxed logger. This moves self so is the last method to call on this object.

pub fn max_level(&self) -> Level[src]

Returns the maximum log Level of any of the child loggers added to this PolyLogger

pub fn add<T: Log + 'static>(&mut self, logger: T)[src]

Adds a logger to this PolyLogger. This can be anything that implements the log::Log interface.

Trait Implementations

impl Debug for PolyLogger[src]

impl Log for PolyLogger[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.