mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-15 04:17:41 +08:00
feat(logManagement): implement log management service
This commit is contained in:
21
Extensions/LoggingExtensions.cs
Normal file
21
Extensions/LoggingExtensions.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user