Split out loggingStart service to its own file and namespace

This commit is contained in:
2022-06-11 21:52:16 +01:00
parent d15571a98d
commit e83cac2838
2 changed files with 37 additions and 39 deletions

View File

@@ -0,0 +1,30 @@
using ILogger = Serilog.ILogger;
namespace Diary.Installers
{
public class LoggingStartService : IHostedService
{
private readonly ILogger _log;
private readonly string _serviceName;
public ILogger Logger { get; }
public LoggingStartService(ILogger logger, string serviceName)
{
_log = logger.ForContext<LoggingStartService>();
_serviceName = serviceName ?? "API";
}
public Task StartAsync(CancellationToken cancellationToken)
{
_log.Information("{ServiceName} service started", _serviceName);
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
_log.Information("{ServiceName} service stopped", _serviceName);
return Task.CompletedTask;
}
}
}