aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-server/src/log.rs
blob: 62d03167bb7af7303477c2f3b6ab0c1e44c80b33 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
//! Logging specifics

const BANNER: &'static str = "
██████╗ ███████╗████████╗    ███╗   ██╗ ██████╗ ██████╗ ███████╗
██╔══██╗██╔════╝╚══██╔══╝    ████╗  ██║██╔═══██╗██╔══██╗██╔════╝
██████╔╝███████╗   ██║       ██╔██╗ ██║██║   ██║██║  ██║█████╗  
██╔══██╗╚════██║   ██║       ██║╚██╗██║██║   ██║██║  ██║██╔══╝  
██║  ██║███████║   ██║       ██║ ╚████║╚██████╔╝██████╔╝███████╗
╚═╝  ╚═╝╚══════╝   ╚═╝       ╚═╝  ╚═══╝ ╚═════╝ ╚═════╝ ╚══════╝";

use tracing_subscriber::{filter::LevelFilter, fmt, EnvFilter};

pub(crate) fn initialise() {
    let filter = EnvFilter::try_from_env("RST_LOG")
        .unwrap_or_default()
        .add_directive(LevelFilter::DEBUG.into())
        .add_directive("async_std=error".parse().unwrap())
        .add_directive("mio=error".parse().unwrap());

    // Initialise the logger
    fmt().with_env_filter(filter).init();
    info!("Initialising server...");
    info!("{}", BANNER);
    info!("Available cores: unknown");
    info!("Available RAM: unknown");
    info!("Version: {}", crate::constants::VERSION);
}

#[macro_export]
macro_rules! fatal {
    () => {
        error!("Unknown failure!");
        std::process::exit(2)
    };
    ($($arg:tt)*) => ({
        error!($($arg)*);
        std::process::exit(2)
    })
}