From effbdeed66e8de8e769b8ac069926ad1a9110e62 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sun, 14 Feb 2021 00:06:14 +0100 Subject: rstnode: refactoring server and client components into rst-core * 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 --- games/rstnode/log.rs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 games/rstnode/log.rs (limited to 'games/rstnode/log.rs') 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) + }) +} -- cgit v1.2.3