mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.2 KiB
51 lines
2.2 KiB
using ErsatzTV.Core; |
|
using ErsatzTV.Core.Domain; |
|
using ErsatzTV.Core.Interfaces.Repositories; |
|
|
|
namespace ErsatzTV.Application.Configuration; |
|
|
|
public class UpdateLoggingSettingsHandler : IRequestHandler<UpdateLoggingSettings, Either<BaseError, Unit>> |
|
{ |
|
private readonly IConfigElementRepository _configElementRepository; |
|
private readonly LoggingLevelSwitches _loggingLevelSwitches; |
|
|
|
public UpdateLoggingSettingsHandler( |
|
LoggingLevelSwitches loggingLevelSwitches, |
|
IConfigElementRepository configElementRepository) |
|
{ |
|
_loggingLevelSwitches = loggingLevelSwitches; |
|
_configElementRepository = configElementRepository; |
|
} |
|
|
|
public async Task<Either<BaseError, Unit>> Handle( |
|
UpdateLoggingSettings request, |
|
CancellationToken cancellationToken) => await ApplyUpdate(request.LoggingSettings); |
|
|
|
private async Task<Unit> ApplyUpdate(LoggingSettingsViewModel loggingSettings) |
|
{ |
|
await _configElementRepository.Upsert(ConfigElementKey.MinimumLogLevel, loggingSettings.DefaultMinimumLogLevel); |
|
_loggingLevelSwitches.DefaultLevelSwitch.MinimumLevel = loggingSettings.DefaultMinimumLogLevel; |
|
|
|
await _configElementRepository.Upsert( |
|
ConfigElementKey.MinimumLogLevelScanning, |
|
loggingSettings.ScanningMinimumLogLevel); |
|
_loggingLevelSwitches.ScanningLevelSwitch.MinimumLevel = loggingSettings.ScanningMinimumLogLevel; |
|
|
|
await _configElementRepository.Upsert( |
|
ConfigElementKey.MinimumLogLevelScheduling, |
|
loggingSettings.SchedulingMinimumLogLevel); |
|
_loggingLevelSwitches.SchedulingLevelSwitch.MinimumLevel = loggingSettings.SchedulingMinimumLogLevel; |
|
|
|
await _configElementRepository.Upsert( |
|
ConfigElementKey.MinimumLogLevelStreaming, |
|
loggingSettings.StreamingMinimumLogLevel); |
|
_loggingLevelSwitches.StreamingLevelSwitch.MinimumLevel = loggingSettings.StreamingMinimumLogLevel; |
|
|
|
await _configElementRepository.Upsert( |
|
ConfigElementKey.MinimumLogLevelHttp, |
|
loggingSettings.HttpMinimumLogLevel); |
|
_loggingLevelSwitches.HttpLevelSwitch.MinimumLevel = loggingSettings.HttpMinimumLogLevel; |
|
|
|
return Unit.Default; |
|
} |
|
}
|
|
|