feat: introduce LAUNCHER_GAME_LOG_FILE_LIMIT
variable for hard log size limit
This commit is contained in:
parent
0e331efc8b
commit
d528d0b1a1
12 changed files with 66 additions and 42 deletions
|
@ -2,6 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub const FOLDER_NAME: &str = "anime-game-launcher";
|
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::<usize>().ok())
|
||||||
|
.unwrap_or(8 * 1024 * 1024); // 8 MiB
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default launcher dir path
|
/// 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`
|
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/anime-game-launcher`
|
||||||
|
|
|
@ -310,12 +310,6 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Create new game.log file to log all the game output
|
// 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"))?;
|
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;
|
let mut written = 0;
|
||||||
|
|
||||||
// Log process output while it's running
|
// 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));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
||||||
// Check if we've written less than a limit amount of data
|
// 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
|
// Redirect stdout to the game.log file
|
||||||
if let Some(stdout) = &mut child.stdout {
|
if let Some(stdout) = &mut child.stdout {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
|
@ -2,6 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub const FOLDER_NAME: &str = "honkers-launcher";
|
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::<usize>().ok())
|
||||||
|
.unwrap_or(8 * 1024 * 1024); // 8 MiB
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default launcher dir path
|
/// Get default launcher dir path
|
||||||
///
|
///
|
||||||
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/honkers-launcher`
|
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/honkers-launcher`
|
||||||
|
|
|
@ -263,12 +263,6 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Create new game.log file to log all the game output
|
// 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"))?;
|
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;
|
let mut written = 0;
|
||||||
|
|
||||||
// Log process output while it's running
|
// 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));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
||||||
// Check if we've written less than a limit amount of data
|
// 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
|
// Redirect stdout to the game.log file
|
||||||
if let Some(stdout) = &mut child.stdout {
|
if let Some(stdout) = &mut child.stdout {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
|
@ -2,6 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub const FOLDER_NAME: &str = "anime-borb-launcher";
|
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::<usize>().ok())
|
||||||
|
.unwrap_or(8 * 1024 * 1024); // 8 MiB
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default launcher dir path
|
/// 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`
|
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/anime-borb-launcher`
|
||||||
|
|
|
@ -253,12 +253,6 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Create new game.log file to log all the game output
|
// 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"))?;
|
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;
|
let mut written = 0;
|
||||||
|
|
||||||
// Log process output while it's running
|
// 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));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
||||||
// Check if we've written less than a limit amount of data
|
// 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
|
// Redirect stdout to the game.log file
|
||||||
if let Some(stdout) = &mut child.stdout {
|
if let Some(stdout) = &mut child.stdout {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
|
@ -2,6 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub const FOLDER_NAME: &str = "honkers-railway-launcher";
|
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::<usize>().ok())
|
||||||
|
.unwrap_or(8 * 1024 * 1024); // 8 MiB
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default launcher dir path
|
/// 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`
|
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/honkers-railway-launcher`
|
||||||
|
|
|
@ -264,12 +264,6 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Create new game.log file to log all the game output
|
// 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"))?;
|
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;
|
let mut written = 0;
|
||||||
|
|
||||||
// Log process output while it's running
|
// 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));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
||||||
// Check if we've written less than a limit amount of data
|
// 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
|
// Redirect stdout to the game.log file
|
||||||
if let Some(stdout) = &mut child.stdout {
|
if let Some(stdout) = &mut child.stdout {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
|
@ -2,6 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub const FOLDER_NAME: &str = "wavey-launcher";
|
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::<usize>().ok())
|
||||||
|
.unwrap_or(8 * 1024 * 1024); // 8 MiB
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default launcher dir path
|
/// Get default launcher dir path
|
||||||
///
|
///
|
||||||
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/wavey-launcher`
|
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/wavey-launcher`
|
||||||
|
|
|
@ -244,12 +244,6 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Create new game.log file to log all the game output
|
// 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"))?;
|
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;
|
let mut written = 0;
|
||||||
|
|
||||||
// Log process output while it's running
|
// 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));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
||||||
// Check if we've written less than a limit amount of data
|
// 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
|
// Redirect stdout to the game.log file
|
||||||
if let Some(stdout) = &mut child.stdout {
|
if let Some(stdout) = &mut child.stdout {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
|
@ -2,6 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub const FOLDER_NAME: &str = "sleepy-launcher";
|
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::<usize>().ok())
|
||||||
|
.unwrap_or(8 * 1024 * 1024); // 8 MiB
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default launcher dir path
|
/// Get default launcher dir path
|
||||||
///
|
///
|
||||||
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/sleepy-launcher`
|
/// If `LAUNCHER_FOLDER` variable is set, then its value will be returned. Otherwise return `$HOME/.local/share/sleepy-launcher`
|
||||||
|
|
|
@ -262,12 +262,6 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Create new game.log file to log all the game output
|
// 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"))?;
|
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;
|
let mut written = 0;
|
||||||
|
|
||||||
// Log process output while it's running
|
// 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));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
||||||
// Check if we've written less than a limit amount of data
|
// 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
|
// Redirect stdout to the game.log file
|
||||||
if let Some(stdout) = &mut child.stdout {
|
if let Some(stdout) = &mut child.stdout {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
Loading…
Reference in a new issue