Add ansi_term for colorful displays!

This commit is contained in:
Sofia 2018-04-16 21:25:46 +03:00
parent 739e68c58f
commit 5b69245697
4 changed files with 10 additions and 5 deletions

1
Cargo.lock generated
View File

@ -192,6 +192,7 @@ dependencies = [
name = "teascade-generator" name = "teascade-generator"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -10,3 +10,4 @@ structopt = "*"
serde = "*" serde = "*"
serde_derive = "*" serde_derive = "*"
regex = "*" regex = "*"
ansi_term = "*"

View File

@ -1,3 +1,5 @@
use ansi_term::Color::{Blue, Cyan, Red, Yellow};
pub struct Logger { pub struct Logger {
log_level: LogLevel, log_level: LogLevel,
} }
@ -11,11 +13,11 @@ impl Logger {
if self.log_level.clone() as i32 >= log_level.clone() as i32 { if self.log_level.clone() as i32 >= log_level.clone() as i32 {
match log_level { match log_level {
LogLevel::QUIET => (), LogLevel::QUIET => (),
LogLevel::SEVERE => eprintln!("[SEVERE]: {}", message.into()), LogLevel::SEVERE => eprintln!("{}: {}", Red.paint("[SEVERE]"), message.into()),
LogLevel::INFO => println!("[INFO]: {}", message.into()), LogLevel::INFO => println!("{}: {}", Cyan.paint("[INFO]"), message.into()),
LogLevel::WARNING => eprintln!("[WARNING]: {}", message.into()), LogLevel::WARNING => println!("{}: {}", Yellow.paint("[WARNING]"), message.into()),
LogLevel::DETAIL => println!("[DETAIL]: {}", message.into()), LogLevel::DETAIL => println!("{}: {}", Blue.paint("[DETAIL]"), message.into()),
LogLevel::DETAILER => println!("[DETAILER]: {}", message.into()), LogLevel::DETAILER => println!("{}: {}", Blue.paint("[DETAILER]"), message.into()),
} }
} }
} }

View File

@ -1,3 +1,4 @@
extern crate ansi_term;
extern crate pulldown_cmark; extern crate pulldown_cmark;
extern crate regex; extern crate regex;
#[macro_use] #[macro_use]