mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
init logger in aquatic_cli_helpers crate
This commit is contained in:
parent
427c0bc7c3
commit
8d58f8bb70
15 changed files with 113 additions and 119 deletions
|
|
@ -1,8 +1,5 @@
|
|||
use anyhow::Context;
|
||||
use aquatic_cli_helpers::run_app_with_cli_and_config;
|
||||
use simplelog::{ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
|
||||
|
||||
use aquatic_http::config::{Config, LogLevel};
|
||||
use aquatic_http::config::Config;
|
||||
|
||||
|
||||
#[global_allocator]
|
||||
|
|
@ -12,33 +9,6 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
|||
fn main(){
|
||||
run_app_with_cli_and_config::<Config>(
|
||||
"aquatic: BitTorrent (HTTP/TLS) tracker",
|
||||
run
|
||||
aquatic_http::run
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// almost identical to ws version
|
||||
fn run(config: Config) -> anyhow::Result<()> {
|
||||
let level_filter = match config.log_level {
|
||||
LogLevel::Off => LevelFilter::Off,
|
||||
LogLevel::Error => LevelFilter::Error,
|
||||
LogLevel::Warn => LevelFilter::Warn,
|
||||
LogLevel::Info => LevelFilter::Info,
|
||||
LogLevel::Debug => LevelFilter::Debug,
|
||||
LogLevel::Trace => LevelFilter::Trace,
|
||||
};
|
||||
|
||||
// Note: logger doesn't seem to pick up thread names. Not a huge loss.
|
||||
let simplelog_config = ConfigBuilder::new()
|
||||
.set_time_to_local(true)
|
||||
.set_location_level(LevelFilter::Off)
|
||||
.build();
|
||||
|
||||
TermLogger::init(
|
||||
level_filter,
|
||||
simplelog_config,
|
||||
TerminalMode::Stderr
|
||||
).context("Couldn't initialize logger")?;
|
||||
|
||||
aquatic_http::run(config)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue