mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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.
This commit is contained in:
parent
f632a4b773
commit
4cf942ac3a
1 changed files with 9 additions and 1 deletions
|
|
@ -80,12 +80,16 @@ namespace Flow.Launcher.Plugin.Program
|
|||
|
||||
public async Task<List<Result>> 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<IProgram>()
|
||||
.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;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue