Browse Source

add iptv request logging (#1594)

pull/1595/head
Jason Dove 1 year ago committed by GitHub
parent
commit
9089e2ee04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 1
      ErsatzTV/Program.cs
  3. 30
      ErsatzTV/Startup.cs

1
CHANGELOG.md

@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -14,6 +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
### Fixed
- Fix antiforgery error caused by reusing existing browser tabs across docker container restarts

1
ErsatzTV/Program.cs

@ -77,6 +77,7 @@ public class Program @@ -77,6 +77,7 @@ public class Program
.MinimumLevel.Override("ErsatzTV.Application.Streaming", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.FFmpeg", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.Controllers.IptvController", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("Serilog.AspNetCore.RequestLoggingMiddleware", LoggingLevelSwitches.StreamingLevelSwitch)
.Destructure.UsingAttributes()
.Enrich.FromLogContext()

30
ErsatzTV/Startup.cs

@ -85,6 +85,7 @@ using Newtonsoft.Json; @@ -85,6 +85,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Refit;
using Serilog;
using Serilog.Events;
namespace ErsatzTV;
@ -492,7 +493,34 @@ public class Startup @@ -492,7 +493,34 @@ public class Startup
app.UseForwardedHeaders();
// app.UseHttpLogging();
// app.UseSerilogRequestLogging();
app.UseSerilogRequestLogging(
options =>
{
options.IncludeQueryInRequestPath = true;
// Emit debug-level events instead of the defaults
options.GetLevel = (httpContext, elapsed, ex) =>
{
if (ex is not null)
{
return LogEventLevel.Error;
}
if (httpContext.Response.StatusCode > 499)
{
return LogEventLevel.Error;
}
if (httpContext.Request.Path.ToUriComponent().StartsWith(
"/iptv",
StringComparison.OrdinalIgnoreCase))
{
return LogEventLevel.Debug;
}
return LogEventLevel.Verbose;
};
});
app.UseRequestLocalization(
options =>

Loading…
Cancel
Save