Limit log file size
This commit is contained in:
parent
c41fddd25e
commit
7a7eba6254
1 changed files with 10 additions and 2 deletions
|
@ -10,6 +10,8 @@ namespace Ryujinx.Common.Logging.Targets
|
||||||
private readonly StreamWriter _logWriter;
|
private readonly StreamWriter _logWriter;
|
||||||
private readonly ILogFormatter _formatter;
|
private readonly ILogFormatter _formatter;
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
private ulong _logLength = 0;
|
||||||
|
private static readonly ulong _maxLogCharacterLength = 500000000;
|
||||||
|
|
||||||
string ILogTarget.Name { get => _name; }
|
string ILogTarget.Name { get => _name; }
|
||||||
|
|
||||||
|
@ -93,10 +95,16 @@ namespace Ryujinx.Common.Logging.Targets
|
||||||
|
|
||||||
public void Log(object sender, LogEventArgs args)
|
public void Log(object sender, LogEventArgs args)
|
||||||
{
|
{
|
||||||
_logWriter.WriteLine(_formatter.Format(args));
|
string toWrite = _formatter.Format(args);
|
||||||
|
_logLength += (ulong)toWrite.Length;
|
||||||
|
if (_logLength <= _maxLogCharacterLength)
|
||||||
|
{
|
||||||
|
_logWriter.WriteLine(toWrite);
|
||||||
_logWriter.Flush();
|
_logWriter.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
|
Loading…
Reference in a new issue