3 releases

0.1.1 Mar 9, 2021
0.1.1-rc.0 Dec 18, 2023
0.1.0 Dec 22, 2020

#1117 in Encoding

43 downloads per month

MIT license

16KB
340 lines

PrimaRsLogger

Version Downloads Documentation

Installation

Just include prima_rs_logger = "^0.1" in your Cargo.toml

Code example

There are two different type of guards:

  • term guard => log stuff as plain string
  • json guard => encode everything in json format
use prima_rs_logger::{info, GuardLoggerCell};

// Singleton logger. Used to free user from manually passing Logger objects around.
static LOGGER_GUARD: GuardLoggerCell = GuardLoggerCell::new();

fn main() {
    let app_name: &str = "myapp";
    let guard = prima_rs_logger::term_guard(app_name);
    LOGGER_GUARD.set(guard).expect("Cannot set global logger guard");
    
    info!("Starting {}", app_name; "meta" => "data");
}

Dependencies

~6–15MB
~178K SLoC