#logger #logging #log #log-messages

multi_log

Logger which passes messages on to any number of other loggers

3 releases

Uses old Rust 2015

0.1.2 Mar 19, 2018
0.1.1 Mar 19, 2018
0.1.0 Mar 19, 2018

#672 in Debugging

Download history 533/week @ 2024-07-26 567/week @ 2024-08-02 525/week @ 2024-08-09 805/week @ 2024-08-16 947/week @ 2024-08-23 446/week @ 2024-08-30 681/week @ 2024-09-06 631/week @ 2024-09-13 638/week @ 2024-09-20 631/week @ 2024-09-27 751/week @ 2024-10-04 708/week @ 2024-10-11 907/week @ 2024-10-18 584/week @ 2024-10-25 505/week @ 2024-11-01 476/week @ 2024-11-08

2,599 downloads per month
Used in 4 crates

MIT license

8KB
75 lines

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.");
}

Dependencies

~87KB