1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use log::{Log, Metadata, Record};
use simple_logger::{set_up_color_terminal, SimpleLogger};

struct WrapperLogger {
    simple_logger: SimpleLogger,
}

impl Log for WrapperLogger {
    fn enabled(&self, metadata: &Metadata) -> bool {
        self.simple_logger.enabled(metadata)
    }

    fn log(&self, record: &Record) {
        self.simple_logger.log(record)
    }

    fn flush(&self) {
        self.simple_logger.flush()
    }
}

fn main() {
    set_up_color_terminal();

    let simple_logger = SimpleLogger::new();
    log::set_max_level(simple_logger.max_level());

    let wrapper_logger = WrapperLogger { simple_logger };
    log::set_boxed_logger(Box::new(wrapper_logger)).unwrap();
}