Add verbose mode and hide logs by default

This commit is contained in:
Maxime Augier 2024-04-20 12:55:57 +02:00
parent cc63f34e9e
commit 6f03f9e4e7

View File

@ -83,12 +83,17 @@ struct CLI {
#[arg(short, long)]
interface: Option<String>,
/// Log measurements to stderr
#[arg(short, long)]
verbose: bool
}
#[tokio::main(flavor="current_thread")]
async fn main() -> Result<()> {
let args = CLI::parse();
let verbose = args.verbose;
let session = bluer::Session::new().await?;
let adapter = match &args.interface {
@ -104,7 +109,7 @@ async fn main() -> Result<()> {
let sniffer_store = Arc::clone(&store);
tokio::spawn(async move {
while let Some(data) = stream.next().await {
eprintln!("Data point: {:?}", data);
if verbose { eprintln!("Data point: {:?}", data) };
sniffer_store.lock().await.insert(data, SystemTime::now());
}
});
@ -118,6 +123,8 @@ async fn main() -> Result<()> {
let host = tokio::net::lookup_host(&args.bind).await?
.next()
.ok_or(anyhow!("Cannot resolve host to bind {}", &args.bind))?;
eprintln!("Binding to {}", host);
Ok(warp::serve(filter).run(host).await)
}