mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-29 04:35:51 +03:00
color log output on terminal
This commit is contained in:
parent
09c3b017b9
commit
de1033ac66
@ -27,3 +27,4 @@ sim = { path = "../sim" }
|
||||
structopt = "0.2"
|
||||
strum = "0.9.0"
|
||||
strum_macros = "0.9.0"
|
||||
yansi = "0.4.0"
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Call the log crate, but pre-set the target.
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! debug {
|
||||
( $( $x:expr ),* ) => {
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ extern crate structopt;
|
||||
extern crate strum;
|
||||
#[macro_use]
|
||||
extern crate strum_macros;
|
||||
extern crate yansi;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
@ -56,10 +56,17 @@ impl Log for LogAdapter {
|
||||
}
|
||||
|
||||
fn log(&self, record: &Record) {
|
||||
use yansi::Paint;
|
||||
|
||||
let line = format!(
|
||||
"[{}] [{}] {}",
|
||||
record.level(),
|
||||
record.target(),
|
||||
Paint::white(record.level()),
|
||||
match record.target() {
|
||||
"UI" => Paint::red("UI"),
|
||||
"sim" => Paint::green("sim"),
|
||||
"map" => Paint::blue("map"),
|
||||
x => Paint::cyan(x),
|
||||
},
|
||||
record.args()
|
||||
);
|
||||
println!("{}", line);
|
||||
|
Loading…
Reference in New Issue
Block a user