1use crate::config::get_config;
14use once_cell::sync::OnceCell;
15use tracing_subscriber::{filter::LevelFilter, fmt, util::SubscriberInitExt, EnvFilter};
16
17static INITIALIZED: OnceCell<()> = OnceCell::new();
18
19pub struct Logger;
20
21impl Logger {
22 pub fn init() {
26 INITIALIZED.get_or_init(|| {
27 setup_logging();
28 get_config().log_info();
29
30 ()
31 });
32 }
33}
34
35fn setup_logging() {
36 fmt()
37 .with_env_filter(
38 EnvFilter::builder()
39 .with_default_directive(LevelFilter::INFO.into())
40 .from_env_lossy(),
41 )
42 .with_ansi(get_config().general.tty)
43 .with_file(false)
44 .with_target(false)
45 .finish()
46 .init();
47}