using System.Collections.Generic; using Robust.Shared.Log; using Serilog.Events; namespace Robust.UnitTesting { /// /// Utility class for testing that logs are indeed being thrown. /// public sealed class LogCatcher : ILogHandler { /// /// Read only list of every log message that was caught since the last flush. /// public IReadOnlyList CaughtLogs => _logs; private readonly List _logs = new(); /// /// Clears all currently caught logs /// public void Flush() { lock (_logs) { _logs.Clear(); } } void ILogHandler.Log(string sawmillName, LogEvent message) { lock (_logs) { _logs.Add(message); } } } }