Browse Source

add searching log category

pull/2251/head
Jason Dove 6 days ago
parent
commit
7ab8315d59
No known key found for this signature in database
  1. 1
      CHANGELOG.md
  2. 5
      ErsatzTV.Application/Configuration/Commands/UpdateLoggingSettingsHandler.cs
  3. 1
      ErsatzTV.Application/Configuration/LoggingSettingsViewModel.cs
  4. 4
      ErsatzTV.Application/Configuration/Queries/GetLoggingSettingsHandler.cs
  5. 1
      ErsatzTV.Core/Domain/ConfigElementKey.cs
  6. 2
      ErsatzTV.Core/LoggingLevelSwitches.cs
  7. 16
      ErsatzTV.Infrastructure/Search/SearchQueryParser.cs
  8. 11
      ErsatzTV/Pages/Settings/LoggingSettings.razor
  9. 4
      ErsatzTV/Program.cs

1
CHANGELOG.md

@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Always tell ffmpeg to stop encoding with a specific duration
- This was removed to try to improve transitions with ffmpeg 7.x, but has been causing issues with other content
- Move search debug logging to its own log category; add `Searching Minimum Log Level` to `Settings` > `Logging`
## [25.3.1] - 2025-07-24
### Fixed

5
ErsatzTV.Application/Configuration/Commands/UpdateLoggingSettingsHandler.cs

@ -36,6 +36,11 @@ public class UpdateLoggingSettingsHandler : IRequestHandler<UpdateLoggingSetting @@ -36,6 +36,11 @@ public class UpdateLoggingSettingsHandler : IRequestHandler<UpdateLoggingSetting
loggingSettings.SchedulingMinimumLogLevel);
_loggingLevelSwitches.SchedulingLevelSwitch.MinimumLevel = loggingSettings.SchedulingMinimumLogLevel;
await _configElementRepository.Upsert(
ConfigElementKey.MinimumLogLevelSearching,
loggingSettings.SearchingMinimumLogLevel);
_loggingLevelSwitches.SearchingLevelSwitch.MinimumLevel = loggingSettings.SearchingMinimumLogLevel;
await _configElementRepository.Upsert(
ConfigElementKey.MinimumLogLevelStreaming,
loggingSettings.StreamingMinimumLogLevel);

1
ErsatzTV.Application/Configuration/LoggingSettingsViewModel.cs

@ -7,6 +7,7 @@ public class LoggingSettingsViewModel @@ -7,6 +7,7 @@ public class LoggingSettingsViewModel
public LogEventLevel DefaultMinimumLogLevel { get; set; }
public LogEventLevel ScanningMinimumLogLevel { get; set; }
public LogEventLevel SchedulingMinimumLogLevel { get; set; }
public LogEventLevel SearchingMinimumLogLevel { get; set; }
public LogEventLevel StreamingMinimumLogLevel { get; set; }
public LogEventLevel HttpMinimumLogLevel { get; set; }
}

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

@ -22,6 +22,9 @@ public class GetLoggingSettingsHandler : IRequestHandler<GetLoggingSettings, Log @@ -22,6 +22,9 @@ public class GetLoggingSettingsHandler : IRequestHandler<GetLoggingSettings, Log
Option<LogEventLevel> maybeSchedulingLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelScheduling);
Option<LogEventLevel> maybeSearchingLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelSearching);
Option<LogEventLevel> maybeStreamingLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelStreaming);
@ -33,6 +36,7 @@ public class GetLoggingSettingsHandler : IRequestHandler<GetLoggingSettings, Log @@ -33,6 +36,7 @@ public class GetLoggingSettingsHandler : IRequestHandler<GetLoggingSettings, Log
DefaultMinimumLogLevel = await maybeDefaultLevel.IfNoneAsync(LogEventLevel.Information),
ScanningMinimumLogLevel = await maybeScanningLevel.IfNoneAsync(LogEventLevel.Information),
SchedulingMinimumLogLevel = await maybeSchedulingLevel.IfNoneAsync(LogEventLevel.Information),
SearchingMinimumLogLevel = await maybeSearchingLevel.IfNoneAsync(LogEventLevel.Information),
StreamingMinimumLogLevel = await maybeStreamingLevel.IfNoneAsync(LogEventLevel.Information),
HttpMinimumLogLevel = await maybeHttpLevel.IfNoneAsync(LogEventLevel.Information)
};

1
ErsatzTV.Core/Domain/ConfigElementKey.cs

@ -9,6 +9,7 @@ public class ConfigElementKey @@ -9,6 +9,7 @@ public class ConfigElementKey
public static ConfigElementKey MinimumLogLevel => new("log.minimum_level");
public static ConfigElementKey MinimumLogLevelScanning => new("log.minimum_level.scanning");
public static ConfigElementKey MinimumLogLevelScheduling => new("log.minimum_level.scheduling");
public static ConfigElementKey MinimumLogLevelSearching => new("log.minimum_level.searching");
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");

2
ErsatzTV.Core/LoggingLevelSwitches.cs

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

16
ErsatzTV.Infrastructure/Search/SearchQueryParser.cs

@ -6,12 +6,12 @@ using Lucene.Net.Analysis.Miscellaneous; @@ -6,12 +6,12 @@ using Lucene.Net.Analysis.Miscellaneous;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.QueryParsers.Classic;
using Lucene.Net.Search;
using Serilog;
using Microsoft.Extensions.Logging;
using Query = Lucene.Net.Search.Query;
namespace ErsatzTV.Infrastructure.Search;
public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCache)
public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCache, ILogger<SearchQueryParser> logger)
{
static SearchQueryParser() => BooleanQuery.MaxClauseCount = 1024 * 4;
@ -54,7 +54,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -54,7 +54,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
if (!string.IsNullOrWhiteSpace(smartCollectionName) && await smartCollectionCache.HasCycle(smartCollectionName))
{
Log.Logger.Error("Smart collection {Name} contains a cycle; will not evaluate", smartCollectionName);
logger.LogError("Smart collection {Name} contains a cycle; will not evaluate", smartCollectionName);
}
else
{
@ -63,7 +63,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -63,7 +63,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
{
if (replaceCount > 100)
{
Log.Logger.Warning("smart_collection query is nested too deep; giving up");
logger.LogWarning("smart_collection query is nested too deep; giving up");
break;
}
@ -75,7 +75,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -75,7 +75,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
if (parsedQuery == replaceResult.Query)
{
Log.Logger.Warning(
logger.LogWarning(
"Failed to replace smart_collection in query; is the syntax correct? Quotes are required. Giving up...");
break;
}
@ -97,7 +97,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -97,7 +97,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
};
Query result = ParseQuery(parsedQuery, parser);
Log.Logger.Debug("Search query parsed from [{Query}] to [{ParsedQuery}]", query, result.ToString());
logger.LogDebug("Search query parsed from [{Query}] to [{ParsedQuery}]", query, result.ToString());
return result;
}
@ -113,7 +113,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -113,7 +113,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
string smartCollectionName = match.Groups[1].Value;
if (await smartCollectionCache.HasCycle(smartCollectionName))
{
Log.Logger.Error(
logger.LogError(
"Smart collection {Name} contains a cycle; will not evaluate",
smartCollectionName);
return new ReplaceResult(query, true);
@ -130,7 +130,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -130,7 +130,7 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
}
catch (Exception ex)
{
Log.Logger.Warning(ex, "Unexpected exception replacing smart collections in search query");
logger.LogWarning(ex, "Unexpected exception replacing smart collections in search query");
return new ReplaceResult(query, true);
}
}

11
ErsatzTV/Pages/Settings/LoggingSettings.razor

@ -47,6 +47,17 @@ @@ -47,6 +47,17 @@
<MudSelectItem Value="@LogEventLevel.Error">Error</MudSelectItem>
</MudSelect>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex">
<MudText>Searching Minimum Log Level</MudText>
</div>
<MudSelect @bind-Value="_loggingSettings.SearchingMinimumLogLevel">
<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>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex">
<MudText>Streaming Minimum Log Level</MudText>

4
ErsatzTV/Program.cs

@ -74,6 +74,9 @@ public class Program @@ -74,6 +74,9 @@ public class Program
"ErsatzTV.Application.Subtitles.ExtractEmbeddedSubtitlesHandler",
LoggingLevelSwitches.SchedulingLevelSwitch)
// searching
.MinimumLevel.Override("ErsatzTV.Infrastructure.Search.SearchQueryParser", LoggingLevelSwitches.SearchingLevelSwitch)
// streaming
.MinimumLevel.Override("ErsatzTV.Application.Streaming", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.FFmpeg", LoggingLevelSwitches.StreamingLevelSwitch)
@ -85,6 +88,7 @@ public class Program @@ -85,6 +88,7 @@ public class Program
LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.Controllers.IptvController", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.Controllers.InternalController", LoggingLevelSwitches.StreamingLevelSwitch)
.MinimumLevel.Override("ErsatzTV.Controllers.TroubleshootController", LoggingLevelSwitches.StreamingLevelSwitch)
// http
.MinimumLevel.Override("Serilog.AspNetCore.RequestLoggingMiddleware", LoggingLevelSwitches.HttpLevelSwitch)

Loading…
Cancel
Save