Refactor the ASP Logger to take advantage of new .net6 features
This commit is contained in:
parent
e01a066920
commit
47299dd1de
2 changed files with 77 additions and 82 deletions
|
@ -1,11 +1,10 @@
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Geekbot.Core.Logger;
|
using Geekbot.Core.Logger;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Geekbot.Web.Logging
|
namespace Geekbot.Web.Logging;
|
||||||
|
|
||||||
|
public class AspLogProvider : ILoggerProvider
|
||||||
{
|
{
|
||||||
public class AspLogProvider : ILoggerProvider
|
|
||||||
{
|
|
||||||
private readonly IGeekbotLogger _geekbotLogger;
|
private readonly IGeekbotLogger _geekbotLogger;
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, AspLogger> _loggers = new ConcurrentDictionary<string, AspLogger>();
|
private readonly ConcurrentDictionary<string, AspLogger> _loggers = new ConcurrentDictionary<string, AspLogger>();
|
||||||
|
@ -24,5 +23,4 @@ namespace Geekbot.Web.Logging
|
||||||
{
|
{
|
||||||
return _loggers.GetOrAdd(categoryName, name => new AspLogger(categoryName, _geekbotLogger));
|
return _loggers.GetOrAdd(categoryName, name => new AspLogger(categoryName, _geekbotLogger));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,11 +1,9 @@
|
||||||
using System;
|
using Geekbot.Core.Logger;
|
||||||
using Geekbot.Core.Logger;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Geekbot.Web.Logging
|
namespace Geekbot.Web.Logging;
|
||||||
|
|
||||||
|
public class AspLogger : ILogger
|
||||||
{
|
{
|
||||||
public class AspLogger : ILogger
|
|
||||||
{
|
|
||||||
private readonly string _categoryName;
|
private readonly string _categoryName;
|
||||||
private readonly IGeekbotLogger _geekbotLogger;
|
private readonly IGeekbotLogger _geekbotLogger;
|
||||||
|
|
||||||
|
@ -67,5 +65,4 @@ namespace Geekbot.Web.Logging
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(level))
|
_ => throw new ArgumentOutOfRangeException(nameof(level))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue