|
|
|
|
@ -20,9 +20,6 @@ namespace Lib.Logging.Loggers |
|
|
|
|
private readonly IFileLoggerFactory _fileLoggerFactory; |
|
|
|
|
private readonly IConsoleLoggerFactory _consoleLoggerFactory; |
|
|
|
|
|
|
|
|
|
private IFileLogger? _fileLogger; |
|
|
|
|
private IConsoleLogger? _consoleLogger; |
|
|
|
|
|
|
|
|
|
public LoggerInitializer(ILog log, IFileLoggerFactory fileLoggerFactory, IConsoleLoggerFactory consoleLoggerFactory) |
|
|
|
|
{ |
|
|
|
|
_log = log; |
|
|
|
|
@ -32,22 +29,13 @@ namespace Lib.Logging.Loggers |
|
|
|
|
|
|
|
|
|
public bool Init() |
|
|
|
|
{ |
|
|
|
|
_fileLogger = _fileLoggerFactory.Create(_logFilePath, _logFileName); |
|
|
|
|
_log.AddLogger(_fileLogger); |
|
|
|
|
IFileLogger fileLogger = _fileLoggerFactory.Create(_logFilePath, _logFileName); |
|
|
|
|
_log.AddLogger(fileLogger); |
|
|
|
|
|
|
|
|
|
_consoleLogger = _consoleLoggerFactory.Create(); |
|
|
|
|
_log.AddLogger(_consoleLogger); |
|
|
|
|
IConsoleLogger consoleLogger = _consoleLoggerFactory.Create(); |
|
|
|
|
_log.AddLogger(consoleLogger); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async ValueTask DisposeAsync() |
|
|
|
|
{ |
|
|
|
|
if (_fileLogger != null) |
|
|
|
|
await _fileLogger.DisposeAsync(); |
|
|
|
|
|
|
|
|
|
if (_consoleLogger != null) |
|
|
|
|
await _consoleLogger.DisposeAsync(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |