From 4cf942ac3aaeffa3bdd0035f689b0311ac9767ba Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 26 Oct 2025 21:01:07 +0800 Subject: [PATCH] Add detailed debug logging for query execution process Enhanced logging to provide better traceability and insights: - Added debug logs for query reception, cache misses, and lock acquisition. - Logged query cancellation and completion with result counts. - Added logs for caching results, including item counts and query details. - Improved logging for filtering and program selection processes. - Ensured no functional changes to existing query and filtering logic. --- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index bb850b4de..088f42817 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -80,12 +80,16 @@ namespace Flow.Launcher.Plugin.Program public async Task> QueryAsync(Query query, CancellationToken token) { + Context.API.LogDebug(ClassName, $"Query received: {query.Search}"); var result = await cache.GetOrCreateAsync(query.Search, async entry => { + Context.API.LogDebug(ClassName, $"Cache miss for query: {query.Search}"); var resultList = await Task.Run(async () => { + Context.API.LogDebug(ClassName, "Acquiring locks for querying programs"); await _win32sLock.WaitAsync(token); await _uwpsLock.WaitAsync(token); + Context.API.LogDebug(ClassName, "Locks acquired for querying programs"); try { // Collect all UWP Windows app directories @@ -95,6 +99,7 @@ namespace Flow.Launcher.Plugin.Program .Select(uwp => uwp.Location.TrimEnd('\\')) // Remove trailing slash .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray() : null; + Context.API.LogDebug(ClassName, "Start filtering and selecting programs"); return _win32s.Cast() .Concat(_uwps) @@ -109,6 +114,7 @@ namespace Flow.Launcher.Plugin.Program } catch (OperationCanceledException) { + Context.API.LogDebug(ClassName, "Query operation was canceled"); return emptyResults; } finally @@ -120,9 +126,11 @@ namespace Flow.Launcher.Plugin.Program resultList = resultList.Count != 0 ? resultList : emptyResults; + Context.API.LogDebug(ClassName, $"Query completed with {resultList.Count} results"); entry.SetSize(resultList.Count); entry.SetSlidingExpiration(TimeSpan.FromHours(8)); - + Context.API.LogDebug(ClassName, $"Caching results for query: {query.Search} with {resultList.Count} items"); + return resultList; });