diff options
Diffstat (limited to 'mumlib/src/lib.rs')
| -rw-r--r-- | mumlib/src/lib.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mumlib/src/lib.rs b/mumlib/src/lib.rs new file mode 100644 index 0000000..ebf2019 --- /dev/null +++ b/mumlib/src/lib.rs @@ -0,0 +1,35 @@ +pub mod command; +pub mod state; + +use colored::*; +use log::*; + +pub fn setup_logger() { + fern::Dispatch::new() + .format(|out, message, record| { + let message = message.to_string(); + out.finish(format_args!( + "{} {}:{}{}{}", + //TODO runtime flag that disables color + match record.level() { + Level::Error => "ERROR".red(), + Level::Warn => "WARN ".yellow(), + Level::Info => "INFO ".normal(), + Level::Debug => "DEBUG".green(), + Level::Trace => "TRACE".normal(), + }, + record.file().unwrap(), + record.line().unwrap(), + if message.chars().any(|e| e == '\n') { + "\n" + } else { + " " + }, + message + )) + }) + .level(log::LevelFilter::Debug) + .chain(std::io::stderr()) + .apply() + .unwrap(); +} |
