-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
38 lines (31 loc) · 1.34 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! # Provides a mock Ambi client that emulates real sensor hardware such as
//! an Edge client.
//!
//! This application emulates a real set of hardware sensors that can report on
//! environmental conditions such as temperature, pressure, humidity, etc.
//!
//! Please see the `ambi` repository for the web backend that this client connects to
//! and the `edge-rs` repository for what this client is emulating.
//!
//! See the `LICENSE` file for Copyright and license details.
//!
use ambi_mock_client::error::PostSchedulerError;
use clap::Parser;
use log::LevelFilter;
fn main() -> Result<(), PostSchedulerError> {
// Parses the provided command line interface arguments and flags
let cli = ambi_mock_client::Cli::parse();
init_logging(cli.debug);
ambi_mock_client::run(&cli)
}
fn init_logging(is_debug: bool) {
let mut logger_builder = env_logger::Builder::new();
match is_debug {
true => logger_builder.filter_level(LevelFilter::Debug),
false => logger_builder.filter_level(LevelFilter::Info),
};
// The format_target is what makes the logs include `ambi_mock_client` everywhere. I left it
// here in case anyone wants to disable it in the future. It is enabled because not all logs
// originate from this crate (reqwest for instance makes a few as well).
logger_builder.format_target(true).init();
}