refactor: Re-order main

This commit is contained in:
Ed Page 2020-03-23 20:38:11 -05:00 committed by Ed Page
parent 5cfe913d03
commit 94ee49b068

View file

@ -12,27 +12,9 @@ mod checks;
mod config;
mod dict;
fn init_logging(level: Option<log::Level>) {
if let Some(level) = level {
let mut builder = env_logger::Builder::new();
builder.filter(None, level.to_level_filter());
if level == log::LevelFilter::Trace {
builder.format_timestamp_secs();
} else {
builder.format(|f, record| {
writeln!(
f,
"[{}] {}",
record.level().to_string().to_lowercase(),
record.args()
)
});
}
builder.init();
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
}
fn run() -> Result<i32, anyhow::Error> {
@ -178,7 +160,25 @@ fn run() -> Result<i32, anyhow::Error> {
}
}
fn main() {
let code = run().unwrap();
std::process::exit(code);
fn init_logging(level: Option<log::Level>) {
if let Some(level) = level {
let mut builder = env_logger::Builder::new();
builder.filter(None, level.to_level_filter());
if level == log::LevelFilter::Trace {
builder.format_timestamp_secs();
} else {
builder.format(|f, record| {
writeln!(
f,
"[{}] {}",
record.level().to_string().to_lowercase(),
record.args()
)
});
}
builder.init();
}
}