From acc2ec173ba5c99f1a400a8bab149aa6159e0698 Mon Sep 17 00:00:00 2001 From: ryqdev Date: Wed, 22 May 2024 00:11:34 +0800 Subject: [PATCH] add color --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/main.rs | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b24aba..285ba48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -894,6 +894,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "com" version = "0.6.0" @@ -1769,6 +1779,7 @@ dependencies = [ "chrono", "clap", "clickhouse", + "colored", "csv", "dotenv", "eframe", diff --git a/Cargo.toml b/Cargo.toml index fe3acdd..ebf9565 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,4 @@ egui = "0.27.2" egui_plot = "0.27.2" eframe = "0.27.2" ibapi = "0.4.3" +colored = "2.1.0" diff --git a/src/main.rs b/src/main.rs index 53a8c03..e0b32bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ mod cmds; mod green; mod err; mod strategy; +use colored::Colorize; use crate::{cmds::{Command, backtest::BackTestCommand, @@ -17,9 +18,9 @@ fn init_log() { writeln!( buf, "{}:{} {} [{}] - {}", - record.file().unwrap_or("unknown"), + record.file().unwrap_or("unknown_file"), record.line().unwrap_or(0), - chrono::Local::now().format("%Y-%m-%dT%H:%M:%S"), + chrono::Local::now().format("%Y-%m-%dT%H:%M:%S").to_string().blue(), record.level(), record.args() )