multi_log

Crates.iomulti_log
lib.rsmulti_log
version0.1.2
sourcesrc
created_at2018-03-19 16:57:14.75122
updated_at2018-03-19 17:34:35.555582
descriptionLogger which passes messages on to any number of other loggers.
homepage
repositoryhttps://github.com/davechallis/multi_log
max_upload_size
id56439
size8,301
Dave Challis (davechallis)

documentation

README

multi_log

A Rust library providing a logger which passes messages on to multiple loggers from a single log call.

Usage

Create a multi_log::MultiLogger that wraps any number of loggers that implement the log::Log trait.

Logging to all these can then be performed using the log crate's macros (debug!, info!, etc.).

Example

#[macro_use] extern crate log;
extern crate env_logger;
extern crate simplelog;
extern crate multi_log;

fn main() {
    // create a new logger from the `env_logger` crate
    let logger_a = Box::new(env_logger::Builder::new().filter(None, log::LevelFilter::Info).build());

    // create a new logger from the `simplelog` crate
    let logger_b = simplelog::SimpleLogger::new(log::LevelFilter::Warn, simplelog::Config::default());

    // wrap them both in a MultiLogger, and initialise as global logger
    multi_log::MultiLogger::init(vec![logger_a, logger_b], log::Level::Info).unwrap();

    warn!("This message should be logged with each logger.");
}
Commit count: 8

cargo fmt