Files
RobustToolbox/Robust.Server/ServerStatus/StatusHost.SawmillWrapper.cs
Tyler Young a3a8a8b3cf Use Kestler for StatusHost (#966)
* implement StatusHost as a minimal Kestler based HTTP Rest service

break up and organize StatusHost

* handle weird disposal mechanics exposed by testing facility
2020-02-09 23:16:16 +01:00

37 lines
1.0 KiB
C#

using System;
using Microsoft.Extensions.Logging;
using Robust.Shared.Interfaces.Log;
namespace Robust.Server.ServerStatus
{
internal sealed partial class StatusHost
{
private class SawmillWrapper : ILogger
{
private ISawmill _sawmill;
public SawmillWrapper(ISawmill sawmill)
=> _sawmill = sawmill;
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
=> _sawmill.Log((Shared.Log.LogLevel) (int) logLevel, formatter(state, exception));
public bool IsEnabled(LogLevel logLevel)
=> (int) logLevel >= (int) (_sawmill.Level ?? (Shared.Log.LogLevel) 0);
public IDisposable BeginScope<TState>(TState state)
=> new DummyDisposable();
// @formatter:off
private struct DummyDisposable : IDisposable { public void Dispose() { } }
// @formatter:on
}
}
}