btcpayserver/BTCPayServer.Common/Logging/Logs.cs

67 lines
1.6 KiB
C#
Raw Normal View History

2017-09-13 08:47:34 +02:00
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BTCPayServer.Logging
{
public class Logs
{
static Logs()
{
Configure(new FuncLoggerFactory(n => NullLogger.Instance));
}
public static void Configure(ILoggerFactory factory)
{
2018-07-01 08:52:11 +02:00
if (factory == null)
Configure(new FuncLoggerFactory(n => NullLogger.Instance));
else
{
Configuration = factory.CreateLogger("Configuration");
PayServer = factory.CreateLogger("PayServer");
Events = factory.CreateLogger("Events");
}
}
public static ILogger Configuration
{
get; set;
}
public static ILogger PayServer
{
get; set;
}
public static ILogger Events
{
get; set;
}
public const int ColumnLength = 16;
}
2017-09-13 08:47:34 +02:00
public class FuncLoggerFactory : ILoggerFactory
{
private Func<string, ILogger> createLogger;
public FuncLoggerFactory(Func<string, ILogger> createLogger)
{
this.createLogger = createLogger;
}
public void AddProvider(ILoggerProvider provider)
{
2017-09-13 08:47:34 +02:00
}
2017-09-13 08:47:34 +02:00
public ILogger CreateLogger(string categoryName)
{
return createLogger(categoryName);
}
2017-09-13 08:47:34 +02:00
public void Dispose()
{
2017-09-13 08:47:34 +02:00
}
}
2017-09-13 08:47:34 +02:00
}