Files
RobustToolbox/Robust.UnitTesting/LogCatcher.cs
T
SilverandGitHub 25926a17b7 Renames SS14.* to Robust.* (#793)
RobustToolbox projects should be named Robust.* 

This PR changes the RobustToolbox projects from SS14.* to Robust.*

Updates SS14.* prefixes/namespaces to Robust.*
Updates SpaceStation14.sln to RobustToolbox.sln
Updates MSBUILD/SS14.* to MSBUILD/Robust.*
Updates CSProject and MSBuild references for the above
Updates git_helper.py
Removes Runserver and Runclient as they are unusable
2019-04-15 20:24:59 -06:00

38 lines
953 B
C#

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