log_wrapper
Just some boilerplate code for a logger wrapped over the log crate that logs to STDOUT. This has a global static ConsoleLogger
struct that over-rides the log::Log
trait. Once this is initiated with the ConsoleLogger::new(loglevel)
, where loglevel is either of trace, debug, info, warn, error, off
, the standard macros from log
crate such as info!
, warn!
, etc. can be used to print and the output will be filtered as per the defined loglevel.
Eg:
somemod/src/main.rc
extern crate log;
use ;
use print_log;
somemod_backend/src/lib.rs
extern crate log;
Output:
Why
This is just the boilerplate code taken from the log crate itself that I wanted to use so that I don't have to type it every time.