From 7a7eba62546f433ad6eec95c15bf31b775c64caa Mon Sep 17 00:00:00 2001 From: jcm Date: Fri, 31 May 2024 23:21:49 -0500 Subject: [PATCH] Limit log file size --- src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs b/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs index 8d4ede96c..521481263 100644 --- a/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs +++ b/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs @@ -10,6 +10,8 @@ namespace Ryujinx.Common.Logging.Targets private readonly StreamWriter _logWriter; private readonly ILogFormatter _formatter; private readonly string _name; + private ulong _logLength = 0; + private static readonly ulong _maxLogCharacterLength = 500000000; string ILogTarget.Name { get => _name; } @@ -93,8 +95,14 @@ namespace Ryujinx.Common.Logging.Targets public void Log(object sender, LogEventArgs args) { - _logWriter.WriteLine(_formatter.Format(args)); - _logWriter.Flush(); + string toWrite = _formatter.Format(args); + _logLength += (ulong)toWrite.Length; + if (_logLength <= _maxLogCharacterLength) + { + _logWriter.WriteLine(toWrite); + _logWriter.Flush(); + } + } public void Dispose()