diff --git a/src/games/genshin/consts.rs b/src/games/genshin/consts.rs index 9425cbe..adde9eb 100644 --- a/src/games/genshin/consts.rs +++ b/src/games/genshin/consts.rs @@ -2,6 +2,16 @@ use std::path::PathBuf; pub const FOLDER_NAME: &str = "anime-game-launcher"; +lazy_static::lazy_static! { + // Limit max amount of log data in a file + // This is needed to stop wine from flushing + // tons of debug info there + pub static ref GAME_LOG_FILE_LIMIT: usize = std::env::var("LAUNCHER_GAME_LOG_FILE_LIMIT") + .ok() + .and_then(|limit| limit.parse::().ok()) + .unwrap_or(8 * 1024 * 1024); // 8 MiB +} + /// Get default launcher dir path /// /// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/anime-game-launcher` diff --git a/src/games/genshin/game.rs b/src/games/genshin/game.rs index ca60b87..6f3dbff 100644 --- a/src/games/genshin/game.rs +++ b/src/games/genshin/game.rs @@ -310,12 +310,6 @@ pub fn run() -> anyhow::Result<()> { // Create new game.log file to log all the game output let mut game_output = std::fs::File::create(consts::launcher_dir()?.join("game.log"))?; - - // Limit max amount of log data in a file - // This is needed to stop wine from flushing - // tons of debug info there - const LOG_FILE_LIMIT: usize = 8 * 1024 * 1024; // 8 MiB - let mut written = 0; // Log process output while it's running @@ -323,7 +317,7 @@ pub fn run() -> anyhow::Result<()> { std::thread::sleep(std::time::Duration::from_secs(3)); // Check if we've written less than a limit amount of data - if written < LOG_FILE_LIMIT { + if written < *consts::GAME_LOG_FILE_LIMIT { // Redirect stdout to the game.log file if let Some(stdout) = &mut child.stdout { let mut buf = Vec::new(); diff --git a/src/games/honkai/consts.rs b/src/games/honkai/consts.rs index fd67495..1788910 100644 --- a/src/games/honkai/consts.rs +++ b/src/games/honkai/consts.rs @@ -2,6 +2,16 @@ use std::path::PathBuf; pub const FOLDER_NAME: &str = "honkers-launcher"; +lazy_static::lazy_static! { + // Limit max amount of log data in a file + // This is needed to stop wine from flushing + // tons of debug info there + pub static ref GAME_LOG_FILE_LIMIT: usize = std::env::var("LAUNCHER_GAME_LOG_FILE_LIMIT") + .ok() + .and_then(|limit| limit.parse::().ok()) + .unwrap_or(8 * 1024 * 1024); // 8 MiB +} + /// Get default launcher dir path /// /// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/honkers-launcher` diff --git a/src/games/honkai/game.rs b/src/games/honkai/game.rs index 50e4103..0b39405 100644 --- a/src/games/honkai/game.rs +++ b/src/games/honkai/game.rs @@ -263,12 +263,6 @@ pub fn run() -> anyhow::Result<()> { // Create new game.log file to log all the game output let mut game_output = std::fs::File::create(consts::launcher_dir()?.join("game.log"))?; - - // Limit max amount of log data in a file - // This is needed to stop wine from flushing - // tons of debug info there - const LOG_FILE_LIMIT: usize = 8 * 1024 * 1024; // 8 MiB - let mut written = 0; // Log process output while it's running @@ -276,7 +270,7 @@ pub fn run() -> anyhow::Result<()> { std::thread::sleep(std::time::Duration::from_secs(3)); // Check if we've written less than a limit amount of data - if written < LOG_FILE_LIMIT { + if written < *consts::GAME_LOG_FILE_LIMIT { // Redirect stdout to the game.log file if let Some(stdout) = &mut child.stdout { let mut buf = Vec::new(); diff --git a/src/games/pgr/consts.rs b/src/games/pgr/consts.rs index f2bc882..b030f67 100644 --- a/src/games/pgr/consts.rs +++ b/src/games/pgr/consts.rs @@ -2,6 +2,16 @@ use std::path::PathBuf; pub const FOLDER_NAME: &str = "anime-borb-launcher"; +lazy_static::lazy_static! { + // Limit max amount of log data in a file + // This is needed to stop wine from flushing + // tons of debug info there + pub static ref GAME_LOG_FILE_LIMIT: usize = std::env::var("LAUNCHER_GAME_LOG_FILE_LIMIT") + .ok() + .and_then(|limit| limit.parse::().ok()) + .unwrap_or(8 * 1024 * 1024); // 8 MiB +} + /// Get default launcher dir path /// /// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/anime-borb-launcher` diff --git a/src/games/pgr/game.rs b/src/games/pgr/game.rs index 38eac84..8d844e8 100644 --- a/src/games/pgr/game.rs +++ b/src/games/pgr/game.rs @@ -253,12 +253,6 @@ pub fn run() -> anyhow::Result<()> { // Create new game.log file to log all the game output let mut game_output = std::fs::File::create(consts::launcher_dir()?.join("game.log"))?; - - // Limit max amount of log data in a file - // This is needed to stop wine from flushing - // tons of debug info there - const LOG_FILE_LIMIT: usize = 8 * 1024 * 1024; // 8 MiB - let mut written = 0; // Log process output while it's running @@ -266,7 +260,7 @@ pub fn run() -> anyhow::Result<()> { std::thread::sleep(std::time::Duration::from_secs(3)); // Check if we've written less than a limit amount of data - if written < LOG_FILE_LIMIT { + if written < *consts::GAME_LOG_FILE_LIMIT { // Redirect stdout to the game.log file if let Some(stdout) = &mut child.stdout { let mut buf = Vec::new(); diff --git a/src/games/star_rail/consts.rs b/src/games/star_rail/consts.rs index 22ee3a9..fb5d658 100644 --- a/src/games/star_rail/consts.rs +++ b/src/games/star_rail/consts.rs @@ -2,6 +2,16 @@ use std::path::PathBuf; pub const FOLDER_NAME: &str = "honkers-railway-launcher"; +lazy_static::lazy_static! { + // Limit max amount of log data in a file + // This is needed to stop wine from flushing + // tons of debug info there + pub static ref GAME_LOG_FILE_LIMIT: usize = std::env::var("LAUNCHER_GAME_LOG_FILE_LIMIT") + .ok() + .and_then(|limit| limit.parse::().ok()) + .unwrap_or(8 * 1024 * 1024); // 8 MiB +} + /// Get default launcher dir path /// /// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/honkers-railway-launcher` diff --git a/src/games/star_rail/game.rs b/src/games/star_rail/game.rs index 943d0d9..14c518e 100644 --- a/src/games/star_rail/game.rs +++ b/src/games/star_rail/game.rs @@ -264,12 +264,6 @@ pub fn run() -> anyhow::Result<()> { // Create new game.log file to log all the game output let mut game_output = std::fs::File::create(consts::launcher_dir()?.join("game.log"))?; - - // Limit max amount of log data in a file - // This is needed to stop wine from flushing - // tons of debug info there - const LOG_FILE_LIMIT: usize = 8 * 1024 * 1024; // 8 MiB - let mut written = 0; // Log process output while it's running @@ -277,7 +271,7 @@ pub fn run() -> anyhow::Result<()> { std::thread::sleep(std::time::Duration::from_secs(3)); // Check if we've written less than a limit amount of data - if written < LOG_FILE_LIMIT { + if written < *consts::GAME_LOG_FILE_LIMIT { // Redirect stdout to the game.log file if let Some(stdout) = &mut child.stdout { let mut buf = Vec::new(); diff --git a/src/games/wuwa/consts.rs b/src/games/wuwa/consts.rs index fef4b61..ff14b69 100644 --- a/src/games/wuwa/consts.rs +++ b/src/games/wuwa/consts.rs @@ -2,6 +2,16 @@ use std::path::PathBuf; pub const FOLDER_NAME: &str = "wavey-launcher"; +lazy_static::lazy_static! { + // Limit max amount of log data in a file + // This is needed to stop wine from flushing + // tons of debug info there + pub static ref GAME_LOG_FILE_LIMIT: usize = std::env::var("LAUNCHER_GAME_LOG_FILE_LIMIT") + .ok() + .and_then(|limit| limit.parse::().ok()) + .unwrap_or(8 * 1024 * 1024); // 8 MiB +} + /// Get default launcher dir path /// /// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/wavey-launcher` diff --git a/src/games/wuwa/game.rs b/src/games/wuwa/game.rs index 5be8dfc..33955df 100644 --- a/src/games/wuwa/game.rs +++ b/src/games/wuwa/game.rs @@ -244,12 +244,6 @@ pub fn run() -> anyhow::Result<()> { // Create new game.log file to log all the game output let mut game_output = std::fs::File::create(consts::launcher_dir()?.join("game.log"))?; - - // Limit max amount of log data in a file - // This is needed to stop wine from flushing - // tons of debug info there - const LOG_FILE_LIMIT: usize = 8 * 1024 * 1024; // 8 MiB - let mut written = 0; // Log process output while it's running @@ -257,7 +251,7 @@ pub fn run() -> anyhow::Result<()> { std::thread::sleep(std::time::Duration::from_secs(3)); // Check if we've written less than a limit amount of data - if written < LOG_FILE_LIMIT { + if written < *consts::GAME_LOG_FILE_LIMIT { // Redirect stdout to the game.log file if let Some(stdout) = &mut child.stdout { let mut buf = Vec::new(); diff --git a/src/games/zzz/consts.rs b/src/games/zzz/consts.rs index 636309d..398b5d2 100644 --- a/src/games/zzz/consts.rs +++ b/src/games/zzz/consts.rs @@ -2,6 +2,16 @@ use std::path::PathBuf; pub const FOLDER_NAME: &str = "sleepy-launcher"; +lazy_static::lazy_static! { + // Limit max amount of log data in a file + // This is needed to stop wine from flushing + // tons of debug info there + pub static ref GAME_LOG_FILE_LIMIT: usize = std::env::var("LAUNCHER_GAME_LOG_FILE_LIMIT") + .ok() + .and_then(|limit| limit.parse::().ok()) + .unwrap_or(8 * 1024 * 1024); // 8 MiB +} + /// Get default launcher dir path /// /// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/sleepy-launcher` diff --git a/src/games/zzz/game.rs b/src/games/zzz/game.rs index f4e1038..8e6ccdf 100644 --- a/src/games/zzz/game.rs +++ b/src/games/zzz/game.rs @@ -262,12 +262,6 @@ pub fn run() -> anyhow::Result<()> { // Create new game.log file to log all the game output let mut game_output = std::fs::File::create(consts::launcher_dir()?.join("game.log"))?; - - // Limit max amount of log data in a file - // This is needed to stop wine from flushing - // tons of debug info there - const LOG_FILE_LIMIT: usize = 8 * 1024 * 1024; // 8 MiB - let mut written = 0; // Log process output while it's running @@ -275,7 +269,7 @@ pub fn run() -> anyhow::Result<()> { std::thread::sleep(std::time::Duration::from_secs(3)); // Check if we've written less than a limit amount of data - if written < LOG_FILE_LIMIT { + if written < *consts::GAME_LOG_FILE_LIMIT { // Redirect stdout to the game.log file if let Some(stdout) = &mut child.stdout { let mut buf = Vec::new();