mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-13 04:30:20 +08:00
22 lines
658 B
C#
22 lines
658 B
C#
using Foxel.Services.Logging;
|
|
|
|
namespace Foxel.Extensions;
|
|
|
|
public static class LoggingExtensions
|
|
{
|
|
public static ILoggingBuilder AddDatabaseLogging(this ILoggingBuilder builder, Action<DatabaseLoggerConfiguration>? configure = null)
|
|
{
|
|
var config = new DatabaseLoggerConfiguration();
|
|
configure?.Invoke(config);
|
|
|
|
builder.Services.Configure<DatabaseLoggerConfiguration>(options =>
|
|
{
|
|
options.MinLevel = config.MinLevel;
|
|
options.Enabled = config.Enabled;
|
|
});
|
|
|
|
builder.Services.AddSingleton<ILoggerProvider, DatabaseLoggerProvider>();
|
|
return builder;
|
|
}
|
|
}
|