diff options
author | Katharina Fey <kookie@spacekookie.de> | 2021-02-14 00:06:14 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2021-02-14 00:06:14 +0100 |
commit | effbdeed66e8de8e769b8ac069926ad1a9110e62 (patch) | |
tree | e4522354e53266204aa9962caccde55d8c815092 /games/rstnode/log.rs | |
parent | 5dab336049dbc6817e9ff212998690f59f6bbfa8 (diff) |
* Add an inbox/ outbox system to server components
* Define a data flow from Request -> computation -> Update
* Create simple handlers to call server or client code for requests
Diffstat (limited to 'games/rstnode/log.rs')
-rw-r--r-- | games/rstnode/log.rs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/games/rstnode/log.rs b/games/rstnode/log.rs new file mode 100644 index 000000000000..6462413952e1 --- /dev/null +++ b/games/rstnode/log.rs @@ -0,0 +1,61 @@ +//! Logging specifics + +const BANNER: &'static str = " +██████╗ ███████╗████████╗ ███╗ ██╗ ██████╗ ██████╗ ███████╗ +██╔══██╗██╔════╝╚══██╔══╝ ████╗ ██║██╔═══██╗██╔══██╗██╔════╝ +██████╔╝███████╗ ██║ ██╔██╗ ██║██║ ██║██║ ██║█████╗ +██╔══██╗╚════██║ ██║ ██║╚██╗██║██║ ██║██║ ██║██╔══╝ +██║ ██║███████║ ██║ ██║ ╚████║╚██████╔╝██████╔╝███████╗ +╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚══════╝"; + +use systemstat::{Platform, System}; +use tracing_subscriber::{filter::LevelFilter, fmt, EnvFilter}; + +#[cfg(not(target_os = "windows"))] +const PLATFORM_DISCLAIMER: &'static str = "Platform: Unspecified *nix-like"; +#[cfg(target_os = "windows")] +static PLATFORM_DISCLAIMER: &'static str = + "WARNING: Windows server hosts are not officially supported!"; + +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("gfx_device_gl=error".parse().unwrap()) + .add_directive("ggez=error".parse().unwrap()) + .add_directive("selectors=error".parse().unwrap()) + .add_directive("gilrs=error".parse().unwrap()) + .add_directive("mio=error".parse().unwrap()); + + // Initialise the logger + fmt().with_env_filter(filter).init(); + info!("Initialising..."); + info!("{}", BANNER); + info!("{}", PLATFORM_DISCLAIMER); + info!("Available cores: {}", num_cpus::get()); + info!("Available RAM: {}", mem()); + info!("Version: {}", crate::constants::VERSION); +} + +fn mem() -> String { + let sys = System::new(); + let mem = sys.memory().unwrap(); + format!( + "{} / {}", + mem.free.to_string_as(true), + mem.total.to_string_as(true) + ) +} + +#[macro_export] +macro_rules! fatal { + () => { + error!("Unknown failure!"); + std::process::exit(2) + }; + ($($arg:tt)*) => ({ + error!($($arg)*); + std::process::exit(2) + }) +} |