From ac7aef54384be15d924fba8c07a5c53be8a58ba4 Mon Sep 17 00:00:00 2001 From: Yiheng He Date: Tue, 17 Dec 2024 13:11:25 +0800 Subject: [PATCH] feat: init logger (#72) --- Cargo.lock | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 ++ src/main.rs | 3 +++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c87d9ca..96099a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + [[package]] name = "aligned-vec" version = "0.5.0" @@ -540,6 +549,29 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -762,6 +794,12 @@ version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "1.5.1" @@ -1658,6 +1696,35 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + [[package]] name = "reqwest" version = "0.12.9" @@ -2187,9 +2254,11 @@ dependencies = [ "clap", "colored", "confy", + "env_logger", "futures", "image", "itertools 0.13.0", + "log", "md5", "reqwest", "rpassword", @@ -2544,7 +2613,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b2b1b5c..57d5482 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,11 @@ chrono = "0.4.39" clap = { version = "4.5.23", features = ["derive"] } colored = "2.1.0" confy = "0.6.1" +env_logger = "0.11.5" futures = "0.3.31" image = { version = "0.25.5", default-features = false, features = ["rayon", "png"]} itertools = "0.13.0" +log = "0.4.22" md5 = "0.7.0" reqwest = { version = "0.12.9", default-features = false, features = ["json", "cookies", "rustls-tls"] } rpassword = "7.3.1" diff --git a/src/main.rs b/src/main.rs index 40a4ccf..3c91ca3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ mod gpa; mod semester; mod subject; +use log::info; use clap::{Parser, Subcommand}; use client::LoginError; use colored::Colorize; @@ -36,6 +37,8 @@ enum Commands { #[tokio::main] async fn main() { + env_logger::init(); + let cli = Cli::parse(); let mut config; if let Some(command) = &cli.command {