aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: 13a9b7fb00b7a16c769ab52cdc8bf5e4103e6b4f (plain) (blame)
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
#![feature(lazy_cell)]

use dotenv::var;
use log::LevelFilter;
use std::fs::File;
use lfm_embed::STATE;

fn main() {
    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);

    
}