From c614e68280967bc9e4e0a85951e09acee4bc1fb6 Mon Sep 17 00:00:00 2001 From: Jia Chao Date: Fri, 12 Jul 2024 10:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=97=A5=E5=BF=97=20log=20?= =?UTF-8?q?=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jia Chao --- src/lib.rs | 14 ++++++++++++++ src/main.rs | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0598d87..43da8d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,3 +3,17 @@ pub use ccutils::Result; mod cli; mod config; mod syncer; + +pub fn cumain() -> Result<()> { + let cli = cli::parse(); + + // 设置日志级别 + match (cli.debug, cli.quiet) { + (true, _) => std::env::set_var("RUST_LOG", "debug"), + (false, true) => std::env::set_var("RUST_LOG", "error"), + _ => {}, + } + ccutils::set_up_logging()?; + + Ok(()) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7a11a9..85cc02e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,3 @@ -fn main() { - println!("Hello, world!"); +fn main() -> cuweb_syncer::Result<()> { + cuweb_syncer::cumain() }