Browse Source

separate request logging into its own category (#1601)

pull/1602/head
Jason Dove 1 year ago committed by GitHub
parent
commit
8c3b8e81ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 3
      ErsatzTV.Application/Configuration/Commands/UpdateGeneralSettingsHandler.cs
  3. 1
      ErsatzTV.Application/Configuration/GeneralSettingsViewModel.cs
  4. 4
      ErsatzTV.Application/Configuration/Queries/GetGeneralSettingsHandler.cs
  5. 1
      ErsatzTV.Core/Domain/ConfigElementKey.cs
  6. 2
      ErsatzTV.Core/LoggingLevelSwitches.cs
  7. 9
      ErsatzTV/Pages/Settings.razor
  8. 5
      ErsatzTV/Program.cs
  9. 6
      ErsatzTV/Services/RunOnce/LoadLoggingLevelService.cs

2
CHANGELOG.md

@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Default value: `false`
- When enabled, embedded text subtitles will be periodically extracted, and considered for playback
- Add `sub_language` and `sub_language_tag` fields to search index
- Add `/iptv` request logging to streaming log category at debug level
- Add `/iptv` request logging in its own log category at debug level
- Add channel guide (XMLTV) template system
- Templates should be copied from `_channel.sbntxt`, `_movie.sbntxt`, `_episode.sbntxt`, or `_musicVideo.sbntxt` which are located in the config subfolder `templates/channel-guide`
- Copy the file, remove the leading underscore from the name, and only make edits to the copied file

3
ErsatzTV.Application/Configuration/Commands/UpdateGeneralSettingsHandler.cs

@ -35,6 +35,9 @@ public class UpdateGeneralSettingsHandler : IRequestHandler<UpdateGeneralSetting @@ -35,6 +35,9 @@ public class UpdateGeneralSettingsHandler : IRequestHandler<UpdateGeneralSetting
await _configElementRepository.Upsert(ConfigElementKey.MinimumLogLevelStreaming, generalSettings.StreamingMinimumLogLevel);
_loggingLevelSwitches.StreamingLevelSwitch.MinimumLevel = generalSettings.StreamingMinimumLogLevel;
await _configElementRepository.Upsert(ConfigElementKey.MinimumLogLevelHttp, generalSettings.HttpMinimumLogLevel);
_loggingLevelSwitches.HttpLevelSwitch.MinimumLevel = generalSettings.HttpMinimumLogLevel;
return Unit.Default;
}
}

1
ErsatzTV.Application/Configuration/GeneralSettingsViewModel.cs

@ -8,4 +8,5 @@ public class GeneralSettingsViewModel @@ -8,4 +8,5 @@ public class GeneralSettingsViewModel
public LogEventLevel ScanningMinimumLogLevel { get; set; }
public LogEventLevel SchedulingMinimumLogLevel { get; set; }
public LogEventLevel StreamingMinimumLogLevel { get; set; }
public LogEventLevel HttpMinimumLogLevel { get; set; }
}

4
ErsatzTV.Application/Configuration/Queries/GetGeneralSettingsHandler.cs

@ -25,12 +25,16 @@ public class GetGeneralSettingsHandler : IRequestHandler<GetGeneralSettings, Gen @@ -25,12 +25,16 @@ public class GetGeneralSettingsHandler : IRequestHandler<GetGeneralSettings, Gen
Option<LogEventLevel> maybeStreamingLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelStreaming);
Option<LogEventLevel> maybeHttpLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelHttp);
return new GeneralSettingsViewModel
{
DefaultMinimumLogLevel = await maybeDefaultLevel.IfNoneAsync(LogEventLevel.Information),
ScanningMinimumLogLevel = await maybeScanningLevel.IfNoneAsync(LogEventLevel.Information),
SchedulingMinimumLogLevel = await maybeSchedulingLevel.IfNoneAsync(LogEventLevel.Information),
StreamingMinimumLogLevel = await maybeStreamingLevel.IfNoneAsync(LogEventLevel.Information),
HttpMinimumLogLevel = await maybeHttpLevel.IfNoneAsync(LogEventLevel.Information)
};
}
}

1
ErsatzTV.Core/Domain/ConfigElementKey.cs

@ -10,6 +10,7 @@ public class ConfigElementKey @@ -10,6 +10,7 @@ public class ConfigElementKey
public static ConfigElementKey MinimumLogLevelScanning => new("log.minimum_level.scanning");
public static ConfigElementKey MinimumLogLevelScheduling => new("log.minimum_level.scheduling");
public static ConfigElementKey MinimumLogLevelStreaming => new("log.minimum_level.streaming");
public static ConfigElementKey MinimumLogLevelHttp => new("log.minimum_level.http");
public static ConfigElementKey FFmpegPath => new("ffmpeg.ffmpeg_path");
public static ConfigElementKey FFprobePath => new("ffmpeg.ffprobe_path");
public static ConfigElementKey FFmpegDefaultProfileId => new("ffmpeg.default_profile_id");

2
ErsatzTV.Core/LoggingLevelSwitches.cs

@ -11,4 +11,6 @@ public class LoggingLevelSwitches @@ -11,4 +11,6 @@ public class LoggingLevelSwitches
public LoggingLevelSwitch SchedulingLevelSwitch { get; } = new();
public LoggingLevelSwitch StreamingLevelSwitch { get; } = new();
public LoggingLevelSwitch HttpLevelSwitch { get; } = new();
}

9
ErsatzTV/Pages/Settings.razor

@ -169,6 +169,15 @@ @@ -169,6 +169,15 @@
<MudSelectItem Value="@LogEventLevel.Warning">Warning</MudSelectItem>
<MudSelectItem Value="@LogEventLevel.Error">Error</MudSelectItem>
</MudSelect>
<MudSelect Class="mt-3"
Label="Request Logging Minimum Log Level"
@bind-Value="_generalSettings.HttpMinimumLogLevel"
For="@(() => _generalSettings.HttpMinimumLogLevel)">
<MudSelectItem Value="@LogEventLevel.Debug">Debug</MudSelectItem>
<MudSelectItem Value="@LogEventLevel.Information">Information</MudSelectItem>
<MudSelectItem Value="@LogEventLevel.Warning">Warning</MudSelectItem>
<MudSelectItem Value="@LogEventLevel.Error">Error</MudSelectItem>
</MudSelect>
</MudForm>
</MudCardContent>
<MudCardActions>

5
ErsatzTV/Program.cs

@ -58,6 +58,7 @@ public class Program @@ -58,6 +58,7 @@ public class Program
LoggingLevelSwitches.ScanningLevelSwitch.MinimumLevel = LogEventLevel.Information;
LoggingLevelSwitches.SchedulingLevelSwitch.MinimumLevel = LogEventLevel.Information;
LoggingLevelSwitches.StreamingLevelSwitch.MinimumLevel = LogEventLevel.Information;
LoggingLevelSwitches.HttpLevelSwitch.MinimumLevel = LogEventLevel.Information;
LoggerConfiguration loggerConfiguration = new LoggerConfiguration()
.ReadFrom.Configuration(Configuration)
@ -78,7 +79,9 @@ public class Program @@ -78,7 +79,9 @@ public class Program
.MinimumLevel.Override("ErsatzTV.FFmpeg", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.Core.FFmpeg.FFmpegLibraryProcessService", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.Controllers.IptvController", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("Serilog.AspNetCore.RequestLoggingMiddleware", LoggingLevelSwitches.StreamingLevelSwitch)
// http
.MinimumLevel.Override("Serilog.AspNetCore.RequestLoggingMiddleware", LoggingLevelSwitches.HttpLevelSwitch)
.Destructure.UsingAttributes()
.Enrich.FromLogContext()

6
ErsatzTV/Services/RunOnce/LoadLoggingLevelService.cs

@ -54,5 +54,11 @@ public class LoadLoggingLevelService : BackgroundService @@ -54,5 +54,11 @@ public class LoadLoggingLevelService : BackgroundService
LoggingLevelSwitches loggingLevelSwitches = scope.ServiceProvider.GetRequiredService<LoggingLevelSwitches>();
loggingLevelSwitches.StreamingLevelSwitch.MinimumLevel = logLevel;
}
foreach (LogEventLevel logLevel in await configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelHttp))
{
LoggingLevelSwitches loggingLevelSwitches = scope.ServiceProvider.GetRequiredService<LoggingLevelSwitches>();
loggingLevelSwitches.HttpLevelSwitch.MinimumLevel = logLevel;
}
}
}

Loading…
Cancel
Save