2026-04-04 13:30:13 +02:00
|
|
|
using Serilog.Configuration;
|
|
|
|
|
using LogViewer.Core;
|
2026-04-05 10:13:12 +02:00
|
|
|
using Serilog.Sinks.LogView.Core.Logging;
|
2026-04-04 13:30:13 +02:00
|
|
|
|
2026-04-05 10:13:12 +02:00
|
|
|
namespace Serilog.Sinks.LogView.Core.Extensions;
|
2026-04-04 13:30:13 +02:00
|
|
|
|
|
|
|
|
public static class DataStoreLoggerSinkExtensions
|
|
|
|
|
{
|
|
|
|
|
public static LoggerConfiguration DataStoreLoggerSink
|
|
|
|
|
(
|
|
|
|
|
this LoggerSinkConfiguration loggerConfiguration,
|
|
|
|
|
Func<ILogDataStore> dataStoreProvider,
|
|
|
|
|
Action<DataStoreLoggerConfiguration>? configuration = null,
|
|
|
|
|
IFormatProvider formatProvider = null!
|
|
|
|
|
)
|
|
|
|
|
=> loggerConfiguration.Sink(new DataStoreLoggerSink(dataStoreProvider, GetConfig(configuration), formatProvider));
|
|
|
|
|
|
|
|
|
|
private static Func<DataStoreLoggerConfiguration> GetConfig(Action<DataStoreLoggerConfiguration>? configuration)
|
|
|
|
|
{
|
|
|
|
|
// convert from Action to Func delegate to pass data
|
|
|
|
|
DataStoreLoggerConfiguration data = new();
|
|
|
|
|
configuration?.Invoke(data);
|
|
|
|
|
return () => data;
|
|
|
|
|
}
|
|
|
|
|
}
|