diff --git a/GSS2.Test/Logging/FileLogger.cs b/GSS2.Test/Logging/FileLogger.cs index c2067bf..09ca46f 100644 --- a/GSS2.Test/Logging/FileLogger.cs +++ b/GSS2.Test/Logging/FileLogger.cs @@ -5,6 +5,7 @@ public sealed class FileLogger : ILogger private readonly string _category; private readonly string _filePath; private static readonly object _lock = new(); + private Queue _linesToWrite = new Queue(); public FileLogger(string category, string filePath) { @@ -37,9 +38,18 @@ public sealed class FileLogger : ILogger lock (_lock) { - File.AppendAllText(_filePath, line + Environment.NewLine); - if (exception != null) - File.AppendAllText(_filePath, exception + Environment.NewLine); + _linesToWrite.Enqueue(line); + try + { + while (_linesToWrite.Count() > 0) + { + File.AppendAllText(_filePath, _linesToWrite.Dequeue() + Environment.NewLine); + if (exception != null) + File.AppendAllText(_filePath, exception + Environment.NewLine); + } + } + catch + { } } } }