Improved logging futher and updated some methods to use LogDebugInformation and to handle exceptions
This commit is contained in:
@@ -74,7 +74,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
List<BaseItem> allItems = [.. _libraryManager.GetItemsResult(query).Items];
|
||||
|
||||
_loggingHelper.LogInformation("Total items: {ItemCount}", allItems.Count);
|
||||
_loggingHelper.LogInformation("Stale items found: {AllItems}", allItems);
|
||||
_loggingHelper.LogDebugInformation("Items found: {AllItems}", allItems);
|
||||
|
||||
List<BaseItem> series = [.. allItems.Where(item => item.GetBaseItemKind() == BaseItemKind.Series)];
|
||||
List<BaseItem> movies = [.. allItems.Where(item => item.GetBaseItemKind() == BaseItemKind.Movie)];
|
||||
@@ -85,6 +85,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
|
||||
List<BaseItem> staleSeasons = [.. series.SelectMany(GetStaleSeasons)];
|
||||
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Starting scan of movies items.");
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
|
||||
@@ -93,26 +94,34 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Stale Movies found: {StaleMovies}", staleMovies.Count);
|
||||
|
||||
if (staleMovies.Count > 0 && Configuration.DebugMode)
|
||||
if (staleMovies.Count > 0)
|
||||
{
|
||||
foreach (var movieInfo in staleMovies)
|
||||
{
|
||||
_loggingHelper.LogDebugInformation("Movie Info: ID: {Id} | Movie Name: {MovieName}", [movieInfo.Id, movieInfo.Name]);
|
||||
_loggingHelper.LogInformation("Movie Info: ID: {Id} | Movie Name: {MovieName}", [movieInfo.Id, movieInfo.Name]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loggingHelper.LogInformation("No stale movies found!");
|
||||
}
|
||||
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Stale seasons found: {StaleSeasons}", staleSeasons.Count);
|
||||
|
||||
if (staleSeasons.Count > 0 && Configuration.DebugMode)
|
||||
if (staleSeasons.Count > 0)
|
||||
{
|
||||
IEnumerable<SeriesInfo> staleSeriesInfo = FindSeriesInfo(staleSeasons);
|
||||
|
||||
foreach (var seriesInfo in staleSeriesInfo)
|
||||
{
|
||||
_loggingHelper.LogDebugInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
|
||||
_loggingHelper.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loggingHelper.LogInformation("No stale seasons found!");
|
||||
}
|
||||
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Ending stale media scan...");
|
||||
@@ -125,7 +134,15 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
{
|
||||
List<BaseItem> staleMovies = [];
|
||||
|
||||
staleMovies.AddRange(movies.Where(_movieHelper.IsMovieStale));
|
||||
try
|
||||
{
|
||||
staleMovies.AddRange(movies.Where(_movieHelper.IsMovieStale));
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_loggingHelper.LogInformation("Arguement Null Exception in GetStaleMovies!");
|
||||
_loggingHelper.LogInformation(ex.Message);
|
||||
}
|
||||
|
||||
return staleMovies;
|
||||
}
|
||||
@@ -136,7 +153,6 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_loggingHelper.LogDebugInformation("Debug data for series: {SeriesName}", item.Name);
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
|
||||
// Gets each season in a show
|
||||
var seasons = _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
ParentId = item.Id,
|
||||
@@ -153,7 +169,17 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
|
||||
_loggingHelper.LogDebugInformation("Season debug information for {SeasonNumber}:", season);
|
||||
|
||||
bool isSeasonDataStale = _seriesHelper.IsSeasonDataStale(episodes);
|
||||
bool isSeasonDataStale = false;
|
||||
|
||||
try
|
||||
{
|
||||
isSeasonDataStale = _seriesHelper.IsSeasonDataStale(episodes);
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_loggingHelper.LogInformation("Arguement Null Exception in GetStaleSeasons!");
|
||||
_loggingHelper.LogInformation(ex.Message);
|
||||
}
|
||||
|
||||
_loggingHelper.LogDebugInformation("End of season debug information for {SeasonNumber}.", season);
|
||||
|
||||
@@ -163,7 +189,6 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogDebugInformation("End of scanning for series: {Series}", item);
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
|
||||
return staleSeasons;
|
||||
}
|
||||
@@ -193,6 +218,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
IEnumerable<TaskTriggerInfo> IScheduledTask.GetDefaultTriggers()
|
||||
{
|
||||
// Run this task every 24 hours
|
||||
// Unnecessary, and will be removed once front end page is ready.
|
||||
yield return new TaskTriggerInfo
|
||||
{
|
||||
Type = TaskTriggerInfoType.IntervalTrigger,
|
||||
|
||||
Reference in New Issue
Block a user