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"
|
structopt = "0.2"
|
||||||
strum = "0.9.0"
|
strum = "0.9.0"
|
||||||
strum_macros = "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.
|
// Call the log crate, but pre-set the target.
|
||||||
|
|
||||||
|
#[allow(unused_macros)]
|
||||||
macro_rules! debug {
|
macro_rules! debug {
|
||||||
( $( $x:expr ),* ) => {
|
( $( $x:expr ),* ) => {
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@ extern crate structopt;
|
|||||||
extern crate strum;
|
extern crate strum;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate strum_macros;
|
extern crate strum_macros;
|
||||||
|
extern crate yansi;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
@ -56,10 +56,17 @@ impl Log for LogAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn log(&self, record: &Record) {
|
fn log(&self, record: &Record) {
|
||||||
|
use yansi::Paint;
|
||||||
|
|
||||||
let line = format!(
|
let line = format!(
|
||||||
"[{}] [{}] {}",
|
"[{}] [{}] {}",
|
||||||
record.level(),
|
Paint::white(record.level()),
|
||||||
record.target(),
|
match record.target() {
|
||||||
|
"UI" => Paint::red("UI"),
|
||||||
|
"sim" => Paint::green("sim"),
|
||||||
|
"map" => Paint::blue("map"),
|
||||||
|
x => Paint::cyan(x),
|
||||||
|
},
|
||||||
record.args()
|
record.args()
|
||||||
);
|
);
|
||||||
println!("{}", line);
|
println!("{}", line);
|
||||||
|
Loading…
Reference in New Issue
Block a user