From c771322a27e889ccf4765406b0110281420c8711 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Tue, 23 Apr 2024 17:45:29 +0000 Subject: [PATCH] misc: log when automagic cache clearing occurs - Log in the info level when automagic cache clearing occurs. Since not everyone have their jellyfin instance set to log Shokofin message at debug level (or below). --- Shokofin/Tasks/AutoClearPluginCacheTask.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Shokofin/Tasks/AutoClearPluginCacheTask.cs b/Shokofin/Tasks/AutoClearPluginCacheTask.cs index 79860444..cb5a12e2 100644 --- a/Shokofin/Tasks/AutoClearPluginCacheTask.cs +++ b/Shokofin/Tasks/AutoClearPluginCacheTask.cs @@ -3,6 +3,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; using Shokofin.API; using Shokofin.Resolvers; @@ -34,6 +35,8 @@ public class AutoClearPluginCacheTask : IScheduledTask, IConfigurableScheduledTa /// public bool IsLogged => false; + private readonly ILogger Logger; + private readonly ShokoAPIManager ApiManager; private readonly ShokoAPIClient ApiClient; @@ -43,8 +46,9 @@ public class AutoClearPluginCacheTask : IScheduledTask, IConfigurableScheduledTa /// /// Initializes a new instance of the class. /// - public AutoClearPluginCacheTask(ShokoAPIManager apiManager, ShokoAPIClient apiClient, ShokoResolveManager resolveManager) + public AutoClearPluginCacheTask(ILogger logger, ShokoAPIManager apiManager, ShokoAPIClient apiClient, ShokoResolveManager resolveManager) { + Logger = logger; ApiManager = apiManager; ApiClient = apiClient; ResolveManager = resolveManager; @@ -69,6 +73,8 @@ public IEnumerable GetDefaultTriggers() /// Task. public Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) { + if (ApiClient.IsCacheStalled || ApiManager.IsCacheStalled || ResolveManager.IsCacheStalled) + Logger.LogInformation("Automagically clearing cacheā€¦"); if (ApiClient.IsCacheStalled) ApiClient.Clear(); if (ApiManager.IsCacheStalled)