Split out loggingStart service to its own file and namespace
This commit is contained in:
30
Installers/LoggingStartService.cs
Normal file
30
Installers/LoggingStartService.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user