Initial commit carried over from private repo. This is V2.
This commit is contained in:
32
code/MessengerApi/Factories/LoggerFactory.cs
Normal file
32
code/MessengerApi/Factories/LoggerFactory.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using MessengerApi.Configuration.Model;
|
||||
|
||||
namespace MessengerApi.Factories
|
||||
{
|
||||
public class LoggerFactory : IServiceProvider
|
||||
{
|
||||
private readonly MessengerConfiguration _configuration;
|
||||
|
||||
public LoggerFactory(MessengerConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public ILogger CreateLogger()
|
||||
{
|
||||
var logger = new ConsoleLogger()
|
||||
{
|
||||
IsDebugOutputEnabled = (this._configuration.Verbosity == Configuration.Enums.LoggingVerbosity.Debug || this._configuration.Verbosity == Configuration.Enums.LoggingVerbosity.Trace)
|
||||
? true : false,
|
||||
IsTraceOutputEnabled = this._configuration.Verbosity == Configuration.Enums.LoggingVerbosity.Trace
|
||||
? true : false
|
||||
};
|
||||
|
||||
return logger;
|
||||
}
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return this.CreateLogger();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user