mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-05-31 14:01:06 +00:00
Add a --log switch
This commit is contained in:
+31
-3
@@ -35,8 +35,36 @@ struct Opts {
|
||||
about = "This is the socket address Telemetry is listening to. This is restricted localhost (127.0.0.1) by default and should be fine for most use cases. If you are using Telemetry in a container, you likely want to set this to '0.0.0.0:8000'"
|
||||
)]
|
||||
socket: std::net::SocketAddr,
|
||||
#[clap(
|
||||
arg_enum,
|
||||
required = false,
|
||||
long = "log",
|
||||
default_value = "info",
|
||||
about = "Log level."
|
||||
)]
|
||||
log_level: LogLevel,
|
||||
}
|
||||
|
||||
#[derive(Clap, Debug, PartialEq)]
|
||||
enum LogLevel {
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
Trace,
|
||||
}
|
||||
|
||||
impl Into<log::LevelFilter> for &LogLevel {
|
||||
fn into(self) -> log::LevelFilter {
|
||||
match self {
|
||||
LogLevel::Error => log::LevelFilter::Error,
|
||||
LogLevel::Warn => log::LevelFilter::Warn,
|
||||
LogLevel::Info => log::LevelFilter::Info,
|
||||
LogLevel::Debug => log::LevelFilter::Debug,
|
||||
LogLevel::Trace => log::LevelFilter::Trace,
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Entry point for connecting nodes
|
||||
#[get("/submit/")]
|
||||
async fn node_route(
|
||||
@@ -127,10 +155,10 @@ async fn health(aggregator: web::Data<Addr<Aggregator>>) -> Result<HttpResponse,
|
||||
/// This can be changed using the `PORT` and `BIND` ENV variables.
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
// SimpleLogger::new().with_level(log::LevelFilter::Info).init().expect("Must be able to start a logger");
|
||||
SimpleLogger::new().with_level(log::LevelFilter::Debug).init().expect("Must be able to start a logger");
|
||||
|
||||
let opts: Opts = Opts::parse();
|
||||
let log_level = &opts.log_level;
|
||||
SimpleLogger::new().with_level(log_level.into()).init().expect("Must be able to start a logger");
|
||||
|
||||
let aggregator = Aggregator::new().start();
|
||||
let factory = LocatorFactory::new();
|
||||
let locator = SyncArbiter::start(4, move || factory.create());
|
||||
|
||||
Reference in New Issue
Block a user