File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ use std::path::PathBuf;
66#[ clap( name = "gitbutler-cli" , about = "A CLI for GitButler" , version = option_env!( "GIX_VERSION" ) ) ]
77pub struct Args {
88 /// Enable tracing for debug and performance information printed to stderr.
9- #[ clap( short = 'd' , long) ]
10- pub trace : bool ,
9+ #[ clap( short = 'd' , long, action = clap :: ArgAction :: Count , ) ]
10+ pub trace : u8 ,
1111 /// Run as if gitbutler-cli was started in PATH instead of the current working directory.
1212 #[ clap( short = 'C' , long, default_value = "." , value_name = "PATH" ) ]
1313 pub current_dir : PathBuf ,
Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ mod command;
1818async fn main ( ) -> Result < ( ) > {
1919 let args: Args = clap:: Parser :: parse ( ) ;
2020
21- if args. trace {
22- trace:: init ( ) ?;
21+ if args. trace > 0 {
22+ trace:: init ( args . trace ) ?;
2323 }
2424 let _op_span = tracing:: info_span!( "cli-op" ) . entered ( ) ;
2525 static CHANNEL : Option < & str > = option_env ! ( "CHANNEL" ) ;
@@ -224,13 +224,17 @@ mod trace {
224224 use tracing_subscriber:: layer:: SubscriberExt ;
225225 use tracing_subscriber:: util:: SubscriberInitExt ;
226226
227- pub fn init ( ) -> anyhow:: Result < ( ) > {
227+ pub fn init ( level : u8 ) -> anyhow:: Result < ( ) > {
228228 tracing_subscriber:: registry ( )
229229 . with (
230230 tracing_forest:: ForestLayer :: from (
231231 tracing_forest:: printer:: PrettyPrinter :: new ( ) . writer ( std:: io:: stderr) ,
232232 )
233- . with_filter ( LevelFilter :: DEBUG ) ,
233+ . with_filter ( match level {
234+ 1 => LevelFilter :: INFO ,
235+ 2 => LevelFilter :: DEBUG ,
236+ _ => LevelFilter :: TRACE ,
237+ } ) ,
234238 )
235239 . init ( ) ;
236240 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments