Iceshrimp.NET/Iceshrimp.Frontend/Core/InMemoryLogger/InMemoryLogger.cs
2024-09-13 21:44:31 +02:00

21 lines
No EOL
598 B
C#

using Microsoft.Extensions.Options;
namespace Iceshrimp.Frontend.Core.InMemoryLogger;
internal class InMemoryLogger(IOptions<InMemoryLoggerConfiguration> config, InMemoryLogService logService) : ILogger
{
public void Log<TState>(
LogLevel logLevel, EventId eventId, TState state, Exception? exception,
Func<TState, Exception?, string> formatter
)
{
logService.Add(formatter(state, exception));
}
public bool IsEnabled(LogLevel logLevel)
{
return config.Value.LogLevel.HasFlag(logLevel);
}
public IDisposable BeginScope<TState>(TState state) where TState : notnull => default!;
}