Skip to content

Commit 92cadd4

Browse files
committed
feat: add logging
1 parent 86bf605 commit 92cadd4

14 files changed

+386
-41
lines changed

Cargo.lock

+245
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ colored = "2.1.0"
1313
serde = { version = "1.0.201", features = ["derive"] }
1414
serde_json = "1.0.117"
1515
atty = "0.2.14"
16-
shellexpand = "3.1.0"
16+
shellexpand = "3.1.0"
17+
log = "0.4.21"
18+
env_logger = "0.11.3"
19+
chrono = "0.4.38"

src/cli.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::commands::*;
22
use clap::{Parser, Subcommand};
33
use std::process;
4+
use log::error;
5+
use crate::logging::setup_logger;
46

57
#[derive(Parser)]
68
#[command(version, author, about, long_about = None, arg_required_else_help = true)]
@@ -72,6 +74,11 @@ enum Commands {
7274
}
7375

7476
pub fn run() {
77+
if let Err(e) = setup_logger() {
78+
eprintln!("Could not setup logger {}", e);
79+
process::exit(1);
80+
}
81+
7582
let cli = Cli::parse();
7683

7784
let result = match &cli.command {
@@ -88,7 +95,7 @@ pub fn run() {
8895
};
8996

9097
if let Err(e) = result {
91-
eprintln!("{}", e);
98+
error!("{}", e);
9299
process::exit(1);
93100
}
94101
}

0 commit comments

Comments
 (0)