aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-server/src/log.rs
diff options
context:
space:
mode:
Diffstat (limited to 'games/rstnode/rst-server/src/log.rs')
-rw-r--r--games/rstnode/rst-server/src/log.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/games/rstnode/rst-server/src/log.rs b/games/rstnode/rst-server/src/log.rs
index 62d03167bb7a..676395134a59 100644
--- a/games/rstnode/rst-server/src/log.rs
+++ b/games/rstnode/rst-server/src/log.rs
@@ -8,8 +8,15 @@ 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()
@@ -19,13 +26,24 @@ pub(crate) fn initialise() {
// Initialise the logger
fmt().with_env_filter(filter).init();
- info!("Initialising server...");
+ info!("Initialising...");
info!("{}", BANNER);
- info!("Available cores: unknown");
- info!("Available RAM: unknown");
+ 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 {
() => {