#colored-logging

rovella_logger

A simple logger that is used by the rovella game library (the rest of the library is still in developement)

4 releases

0.1.4 Aug 5, 2022
0.1.3 Jul 16, 2022
0.1.2 Jul 16, 2022
0.1.1 Jul 16, 2022
0.1.0 Jul 16, 2022

#631 in Debugging

30 downloads per month
Used in rovella

GPL-2.0-or-later

5KB
74 lines

The Rovella Logger

This is a simple low overhead logger than uses eprintln and println with format to log text and other data.

Examples

The fatal macro is shown below and the other macros follow this pattern

macro_rules! log_fatal {
    ($($args:tt)*) => {
        eprintln!("\x1b[1;92m{} \x1b[30;41m[FATAL]: {} \x1b[0m",
            format!("[{}:{}]", file!(), line!()),
            format!($($args)*),
        );
    };
}

The macro can be used just like println but it gives some extra info (along with color)

#[macro_use]
extern crate rovella_logger;
...

log_fatal!("Fatal error with code: {}", 4); // output => [src\main.rs:2] [FATAL]: Fatal error with code: 4 
log_fatal!("Fatal");                        // output => [src\main.rs:3] [FATAL]: Fatal

Macros with a security level below error don't compile to anything in release mode

#[macro_use]
extern crate rovella_logger;
...

log_warn!("I'm only in debug mode {}", 4); // output => ...
log_info!("I'm only in deubg mode");       // output => ...

No runtime deps