From c74ce52c2dc7b2f2f374cce7480ba650ed8b3bfb Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 28 May 2023 19:11:31 +0800 Subject: [PATCH] refactor: add colored log --- Cargo.lock | 32 ++++++++++++++++++++++++++++++++ gpgui/src-tauri/Cargo.toml | 4 +++- gpgui/src-tauri/src/main.rs | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 61a72d0..98ea59d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,17 @@ dependencies = [ "url", ] +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -351,6 +362,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + [[package]] name = "combine" version = "4.6.6" @@ -693,6 +715,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" dependencies = [ + "colored", "log", ] @@ -1203,6 +1226,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.2.6" diff --git a/gpgui/src-tauri/Cargo.toml b/gpgui/src-tauri/Cargo.toml index 58223d2..6b21661 100644 --- a/gpgui/src-tauri/Cargo.toml +++ b/gpgui/src-tauri/Cargo.toml @@ -17,7 +17,9 @@ tauri-build = { version = "1.3", features = [] } [dependencies] gpcommon = { path = "../../gpcommon" } tauri = { version = "1.3", features = ["http-all", "window-data-url"] } -tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } +tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1", features = [ + "colored", +] } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } log = "0.4" diff --git a/gpgui/src-tauri/src/main.rs b/gpgui/src-tauri/src/main.rs index e1f0223..0191ba8 100644 --- a/gpgui/src-tauri/src/main.rs +++ b/gpgui/src-tauri/src/main.rs @@ -50,6 +50,7 @@ fn main() { LogTarget::Stdout, /*LogTarget::Webview*/ ]) .level(log::LevelFilter::Info) + .with_colors(Default::default()) .build(), ) .setup(setup)