feat: add hard limit to the game log file size
This commit is contained in:
parent
a72d1fb05c
commit
0c34ca2b31
6 changed files with 198 additions and 114 deletions
|
@ -311,10 +311,19 @@ 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
|
||||
while child.try_wait()?.is_none() {
|
||||
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 {
|
||||
// Redirect stdout to the game.log file
|
||||
if let Some(stdout) = &mut child.stdout {
|
||||
let mut buf = Vec::new();
|
||||
|
@ -326,6 +335,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b" [stdout] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,6 +352,9 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b"[!] [stderr] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,10 +264,19 @@ 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
|
||||
while child.try_wait()?.is_none() {
|
||||
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 {
|
||||
// Redirect stdout to the game.log file
|
||||
if let Some(stdout) = &mut child.stdout {
|
||||
let mut buf = Vec::new();
|
||||
|
@ -279,6 +288,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b" [stdout] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +305,9 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b"[!] [stderr] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,10 +254,19 @@ 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
|
||||
while child.try_wait()?.is_none() {
|
||||
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 {
|
||||
// Redirect stdout to the game.log file
|
||||
if let Some(stdout) = &mut child.stdout {
|
||||
let mut buf = Vec::new();
|
||||
|
@ -269,6 +278,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b" [stdout] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +295,9 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b"[!] [stderr] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,10 +265,19 @@ 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
|
||||
while child.try_wait()?.is_none() {
|
||||
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 {
|
||||
// Redirect stdout to the game.log file
|
||||
if let Some(stdout) = &mut child.stdout {
|
||||
let mut buf = Vec::new();
|
||||
|
@ -280,6 +289,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b" [stdout] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,6 +306,9 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b"[!] [stderr] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,10 +245,19 @@ 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
|
||||
while child.try_wait()?.is_none() {
|
||||
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 {
|
||||
// Redirect stdout to the game.log file
|
||||
if let Some(stdout) = &mut child.stdout {
|
||||
let mut buf = Vec::new();
|
||||
|
@ -260,6 +269,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b" [stdout] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,6 +286,9 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b"[!] [stderr] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,10 +263,19 @@ 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
|
||||
while child.try_wait()?.is_none() {
|
||||
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 {
|
||||
// Redirect stdout to the game.log file
|
||||
if let Some(stdout) = &mut child.stdout {
|
||||
let mut buf = Vec::new();
|
||||
|
@ -278,6 +287,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b" [stdout] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,6 +304,9 @@ pub fn run() -> anyhow::Result<()> {
|
|||
game_output.write_all(b"[!] [stderr] ")?;
|
||||
game_output.write_all(line)?;
|
||||
game_output.write_all(b"\n")?;
|
||||
|
||||
written += line.len() + 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue