diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index e7a11a9..13a9b7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,27 @@ +#![feature(lazy_cell)] + +use dotenv::var; +use log::LevelFilter; +use std::fs::File; +use lfm_embed::STATE; + fn main() { - println!("Hello, world!"); + env_logger::Builder::new() + .filter_level(LevelFilter::Warn) + .parse_filters(&var("LFME_LOG_LEVEL").unwrap_or_default()) + .target( + var("LFME_LOG_FILE").ok() + .map( + |f| env_logger::Target::Pipe( + Box::new(File::options() + .append(true) + .open(f) + .expect("couldn't open LFME_LOG_FILE"))) + ) + .unwrap_or(env_logger::Target::Stderr) + ).init(); + + std::sync::LazyLock::force(&STATE); + + } |