mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-21 13:03:41 +01:00
28 lines
649 B
C#
28 lines
649 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Tgstation.Server.Tests.Live
|
|
{
|
|
sealed class HardFailLoggerProvider : ILoggerProvider
|
|
{
|
|
public static bool BlockFails { get; set; }
|
|
|
|
public static Task FailureSource => failureSink.Task;
|
|
|
|
static readonly TaskCompletionSource failureSink = new (TaskCreationOptions.RunContinuationsAsynchronously);
|
|
|
|
public ILogger CreateLogger(string categoryName) => new HardFailLogger(ex =>
|
|
{
|
|
if (!BlockFails)
|
|
{
|
|
Console.WriteLine("UNEXPECTED ERROR OCCURS NEAR HERE");
|
|
failureSink.TrySetException(ex);
|
|
}
|
|
});
|
|
|
|
public void Dispose() { }
|
|
}
|
|
}
|