btcpayserver/BTCPayServer.Common/Logging/Logs.cs

64 lines
1.5 KiB
C#
Raw Normal View History

2020-06-28 21:44:35 -05:00
using System;
2020-06-28 17:55:27 +09:00
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
2017-09-13 15:47:34 +09:00
namespace BTCPayServer.Logging
{
public class Logs
{
2021-11-22 17:16:08 +09:00
public Logs()
{
Configure(new FuncLoggerFactory(n => NullLogger.Instance));
}
2021-11-22 17:16:08 +09:00
public void Configure(ILoggerFactory factory)
{
2018-07-01 15:52:11 +09:00
if (factory == null)
Configure(new FuncLoggerFactory(n => NullLogger.Instance));
else
{
Configuration = factory.CreateLogger("Configuration");
PayServer = factory.CreateLogger("PayServer");
Events = factory.CreateLogger("Events");
}
}
2021-11-22 17:16:08 +09:00
public ILogger Configuration
{
get; set;
}
2021-11-22 17:16:08 +09:00
public ILogger PayServer
{
get; set;
}
2021-11-22 17:16:08 +09:00
public ILogger Events
{
get; set;
}
public const int ColumnLength = 16;
}
2017-09-13 15:47:34 +09:00
public class FuncLoggerFactory : ILoggerFactory
{
private readonly Func<string, ILogger> createLogger;
public FuncLoggerFactory(Func<string, ILogger> createLogger)
{
this.createLogger = createLogger;
}
public void AddProvider(ILoggerProvider provider)
{
2017-09-13 15:47:34 +09:00
}
2017-09-13 15:47:34 +09:00
public ILogger CreateLogger(string categoryName)
{
return createLogger(categoryName);
}
2017-09-13 15:47:34 +09:00
public void Dispose()
{
2017-09-13 15:47:34 +09:00
}
}
2017-09-13 15:47:34 +09:00
}