main.rs: Add a flag for trace-level logs

This commit is contained in:
Nick Mathewson 2020-10-20 11:49:23 -04:00
parent 7ce158ed1e
commit 31cde26138
1 changed files with 10 additions and 2 deletions

View File

@ -46,6 +46,9 @@ struct Args {
/// try doing a download test (to 127.0.0.1:9999)? Requires chutney. /// try doing a download test (to 127.0.0.1:9999)? Requires chutney.
#[argh(switch)] #[argh(switch)]
dl: bool, dl: bool,
/// enable trace-level logging
#[argh(switch)]
trace: bool,
} }
/// Launch an authenticated channel to a relay. /// Launch an authenticated channel to a relay.
@ -161,10 +164,15 @@ fn get_netdir(args: &Args) -> Result<tor_netdir::NetDir> {
} }
fn main() -> Result<()> { fn main() -> Result<()> {
simple_logging::log_to_stderr(LevelFilter::Debug);
let args: Args = argh::from_env(); let args: Args = argh::from_env();
let filt = if args.trace {
LevelFilter::Trace
} else {
LevelFilter::Debug
};
simple_logging::log_to_stderr(filt);
if args.chutney_dir.is_none() && (args.flood || args.dl) { if args.chutney_dir.is_none() && (args.flood || args.dl) {
eprintln!("--flood and --dl both require --chutney-dir."); eprintln!("--flood and --dl both require --chutney-dir.");
return Ok(()); return Ok(());