Add verbose mode and hide logs by default
This commit is contained in:
parent
cc63f34e9e
commit
6f03f9e4e7
11
src/main.rs
11
src/main.rs
@ -15,7 +15,7 @@ const VENDOR_ID_SENSIRION: u16 = 0x06d5;
|
||||
struct Data {
|
||||
|
||||
/// ID
|
||||
addr: Address,
|
||||
addr: Address,
|
||||
|
||||
/// Temperature in °C
|
||||
temperature: f32,
|
||||
@ -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)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user