Skip to content

Conversation

Jack251970
Copy link
Member

Improve log

For all other projects, we use API to get log functions.

For Infrastructure project, we use Log static class to get log functions.

Ignore plugin source http exception

Ignore exceptions like:


Please open new issue in https://github.com/Flow-Launcher/Flow.Launcher/issues
1. Upload log file: C:\Users\11602\AppData\Roaming\FlowLauncher\Logs\1.19.5\2025-04-13.txt
2. Copy below exception message

Flow Launcher version: 1.19.5
OS Version: 26100.3775
IntPtr Length: 8
x64: True

Python Path: C:\Users\11602\AppData\Roaming\FlowLauncher\Environments\Python\PythonEmbeddable-v3.11.4\pythonw.exe
Node Path: C:\Program Files\nodejs\node.exe

Date: 04/13/2025 15:45:04
Exception:
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (The requested address is not valid in its context. (raw.githubusercontent.com:443))
 ---> System.Net.Http.HttpRequestException: The requested address is not valid in its context. (raw.githubusercontent.com:443)
 ---> System.Net.Sockets.SocketException (10049): The requested address is not valid in its context.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Flow.Launcher.Infrastructure.Http.Http.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken token) in C:\projects\flow-launcher\Flow.Launcher.Infrastructure\Http\Http.cs:line 214
   at Flow.Launcher.Core.ExternalPlugins.CommunityPluginSource.FetchAsync(CancellationToken token) in C:\projects\flow-launcher\Flow.Launcher.Core\ExternalPlugins\CommunityPluginSource.cs:line 43
   --- End of inner exception stack trace ---

This comment has been minimized.

Copy link

gitstream-cm bot commented Apr 13, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

coderabbitai bot commented Apr 13, 2025

📝 Walkthrough

Walkthrough

This pull request refactors logging and error handling across multiple modules. Most changes replace direct static logging (e.g., using Log.Exception, Log.Info, etc.) with API-based logging calls that incorporate a consistent ClassName variable for context. In several environment classes, blocking calls have been replaced by asynchronous execution using a JoinableTaskFactory. Additional minor changes include code formatting adjustments, removal of unused dependencies, and simplified property implementations.

Changes

File(s) Change Summary
Flow.Launcher.Core/{Configuration/Portable.cs, ExternalPlugins/CommunityPluginSource.cs, Environments/AbstractPluginEnvironment.cs, Plugin/PluginConfig.cs, Plugin/PluginManager.cs, Resource/Internationalization.cs, Resource/Theme.cs, Updater.cs} Refactored logging calls by replacing static log methods with API logging calls; introduced a ClassName field for consistent contextual logging; rearranged using directives.
Flow.Launcher.Core/ExternalPlugins/Environments/{PythonEnvironment.cs, TypeScriptEnvironment.cs, TypeScriptV2Environment.cs} Implemented asynchronous environment installation by introducing a JoinableTaskFactory to replace blocking calls with non‑blocking JTF.Run execution.
Flow.Launcher.Infrastructure/{Http/Http.cs, Storage/BinaryStorage.cs, Storage/JsonStorage.cs, Storage/{PluginBinaryStorage.cs, PluginJsonStorage.cs}, Stopwatch.cs, Logger/Log.cs} Improved logging consistency by updating HttpClient initialization (made readonly), adding ClassName fields in storage classes, modifying property getters, and removing redundant API dependencies in logging.
Flow.Launcher/{App.xaml.cs, MessageBoxEx.xaml.cs, AutoStartup.cs, HotKeyMapper.cs, WallpaperPathRetrieval.cs, Notification.cs, ProgressBoxEx.xaml.cs, SettingWindow.xaml.cs, ViewModel/{MainViewModel.cs, ResultViewModel.cs}, ReportWindow.xaml.cs, Msg.xaml.cs} Standardized UI and ViewModel logging to use App.API with the new ClassName variable; removed instance-based API references and unused imports; updated log message paths.
Plugins/Flow.Launcher.Plugin/{BrowserBookmark/Main.cs, Explorer/{ContextMenu.cs, Search/DirectoryInfo/DirectoryInfoSearch.cs}, ProcessKiller/ProcessHelper.cs, WebSearch/SuggestionSources/{Baidu.cs, Bing.cs, DuckDuckGo.cs, Google.cs}, WindowsSettings/Log.cs, Program/Main.cs} Standardized plugin logging by adding ClassName fields and updating logging calls to API methods; removed redundant log calls (e.g., for canceled operations) for improved maintainability.
Flow.Launcher/PublicAPIInstance.cs Modified logging method implementations by passing parameters directly to the Stopwatch methods, simplifying message formatting and parameter handling.
Flow.Launcher.Core/ExternalPlugins/Environments/{JavaScriptEnvironment.cs, JavaScriptV2Environment.cs} Made minor formatting updates by removing extraneous blank lines and unused code without affecting functionality.

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment (Python/TypeScript)
    participant JTF as JoinableTaskFactory
    participant Droplex as DroplexPackage
    participant API as Logging API

    Env->>JTF: Run(DroplexPackage.Drop)
    alt Successful Execution
      JTF-->>Env: Return Result
      Env->>API: Log success (using ClassName)
    else Exception Occurs
      JTF-->>Env: Raise Exception
      Env->>API: Log exception (using ClassName)
    end
Loading

Poem

I'm a little rabbit, hopping through the code,
Finding log lines in every node.
With a swift API call replacing the old,
My ClassName shines, a story told.
As async paths free up the load,
I smile with joy on this refactor road.
🐰 Happy coding!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs (1)

42-42: Changed from API-based logging to direct Log calls.

Same observation as line 30 - the direction of change is opposite to other files in this PR.

🧹 Nitpick comments (3)
Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs (1)

23-23: Consider using nameof operator for class name consistency.

Using a hardcoded string "BinaryStorage" could lead to inconsistencies if the class name changes in the future. Consider using nameof(BinaryStorage<T>) instead, which would automatically update if the class is renamed and match the pattern used in other files.

-    private static readonly string ClassName = "BinaryStorage";
+    private static readonly string ClassName = nameof(BinaryStorage<T>);
Flow.Launcher.Infrastructure/Storage/JsonStorage.cs (2)

19-20: Good addition of class name constant for logging with minor consideration.

Using a string literal "JsonStorage" instead of nameof() is reasonable for a generic class, as nameof would produce "JsonStorage`1". However, this approach loses the refactoring safety that nameof() provides.

Consider using a clearer name like "JsonStorageGeneric" to indicate this is for the generic class, or you could use nameof(JsonStorage<T>).Split('')[0]` to get "JsonStorage" programmatically.


109-109: Improved consistency in logging.

Using the ClassName variable instead of a hardcoded string improves consistency and maintainability.

Note that unlike other files in this PR, you're still using direct Log.Info instead of an API abstraction. Consider standardizing this approach across all files if appropriate.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5d22a and 20d2661.

📒 Files selected for processing (48)
  • Flow.Launcher.Core/Configuration/Portable.cs (3 hunks)
  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (2 hunks)
  • Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs (2 hunks)
  • Flow.Launcher.Core/ExternalPlugins/Environments/JavaScriptEnvironment.cs (0 hunks)
  • Flow.Launcher.Core/ExternalPlugins/Environments/JavaScriptV2Environment.cs (0 hunks)
  • Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs (2 hunks)
  • Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs (2 hunks)
  • Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs (2 hunks)
  • Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs (2 hunks)
  • Flow.Launcher.Core/Plugin/PluginConfig.cs (5 hunks)
  • Flow.Launcher.Core/Plugin/PluginManager.cs (5 hunks)
  • Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs (2 hunks)
  • Flow.Launcher.Core/Resource/Internationalization.cs (6 hunks)
  • Flow.Launcher.Core/Resource/Theme.cs (7 hunks)
  • Flow.Launcher.Core/Updater.cs (4 hunks)
  • Flow.Launcher.Infrastructure/Http/Http.cs (8 hunks)
  • Flow.Launcher.Infrastructure/Image/ImageLoader.cs (6 hunks)
  • Flow.Launcher.Infrastructure/Logger/Log.cs (0 hunks)
  • Flow.Launcher.Infrastructure/Stopwatch.cs (2 hunks)
  • Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs (3 hunks)
  • Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs (3 hunks)
  • Flow.Launcher.Infrastructure/Storage/JsonStorage.cs (2 hunks)
  • Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs (3 hunks)
  • Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs (3 hunks)
  • Flow.Launcher/App.xaml.cs (6 hunks)
  • Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (2 hunks)
  • Flow.Launcher/Helper/AutoStartup.cs (7 hunks)
  • Flow.Launcher/Helper/HotKeyMapper.cs (4 hunks)
  • Flow.Launcher/Helper/WallpaperPathRetrieval.cs (5 hunks)
  • Flow.Launcher/MessageBoxEx.xaml.cs (2 hunks)
  • Flow.Launcher/Msg.xaml.cs (0 hunks)
  • Flow.Launcher/Notification.cs (2 hunks)
  • Flow.Launcher/ProgressBoxEx.xaml.cs (2 hunks)
  • Flow.Launcher/PublicAPIInstance.cs (1 hunks)
  • Flow.Launcher/ReportWindow.xaml.cs (2 hunks)
  • Flow.Launcher/SettingWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (5 hunks)
  • Flow.Launcher/ViewModel/ResultViewModel.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs (0 hunks)
  • Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs (3 hunks)
  • Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/DuckDuckGo.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.WindowsSettings/Log.cs (1 hunks)
💤 Files with no reviewable changes (5)
  • Flow.Launcher.Core/ExternalPlugins/Environments/JavaScriptV2Environment.cs
  • Flow.Launcher/Msg.xaml.cs
  • Flow.Launcher.Core/ExternalPlugins/Environments/JavaScriptEnvironment.cs
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs
  • Flow.Launcher.Infrastructure/Logger/Log.cs
🧰 Additional context used
🧬 Code Graph Analysis (17)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs (1)
Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (1)
  • LogException (472-475)
Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs (4)
Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs (1)
  • InstallEnvironment (36-45)
Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs (1)
  • InstallEnvironment (33-40)
Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs (1)
  • InstallEnvironment (132-132)
Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs (2)
  • FilesFolders (14-367)
  • RemoveFolderIfExists (115-131)
Flow.Launcher/Helper/HotKeyMapper.cs (2)
Flow.Launcher/App.xaml.cs (2)
  • App (27-360)
  • App (51-115)
Flow.Launcher/PublicAPIInstance.cs (1)
  • LogError (216-217)
Flow.Launcher/ProgressBoxEx.xaml.cs (2)
Flow.Launcher/App.xaml.cs (2)
  • App (27-360)
  • App (51-115)
Flow.Launcher/PublicAPIInstance.cs (1)
  • LogError (216-217)
Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs (4)
Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs (1)
  • InstallEnvironment (36-45)
Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs (1)
  • InstallEnvironment (33-40)
Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs (1)
  • InstallEnvironment (132-132)
Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs (2)
  • FilesFolders (14-367)
  • RemoveFolderIfExists (115-131)
Flow.Launcher.Core/Plugin/PluginManager.cs (4)
Flow.Launcher/PublicAPIInstance.cs (2)
  • LogInfo (210-211)
  • LogException (219-220)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (2)
  • LogInfo (256-256)
  • LogException (272-272)
Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs (1)
  • LogInfo (148-151)
Flow.Launcher.Infrastructure/Logger/Log.cs (2)
  • Exception (104-114)
  • Exception (164-182)
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (1)
Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (1)
  • LogException (472-475)
Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs (2)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs (1)
  • Main (16-257)
Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (1)
  • LogException (472-475)
Flow.Launcher/ReportWindow.xaml.cs (1)
Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs (1)
  • DataLocation (6-43)
Flow.Launcher/ViewModel/ResultViewModel.cs (2)
Flow.Launcher/ViewModel/ResultsViewModel.cs (3)
  • ResultsViewModel (16-350)
  • ResultsViewModel (26-30)
  • ResultsViewModel (32-48)
Flow.Launcher/PublicAPIInstance.cs (1)
  • LogException (219-220)
Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs (5)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs (1)
  • Main (16-257)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (1)
  • Main (19-462)
Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1)
  • Main (16-450)
Plugins/Flow.Launcher.Plugin.Sys/Main.cs (1)
  • Main (19-516)
Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (1)
  • LogException (472-475)
Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (2)
Flow.Launcher/App.xaml.cs (2)
  • App (27-360)
  • App (51-115)
Flow.Launcher/PublicAPIInstance.cs (1)
  • LogException (219-220)
Flow.Launcher.Core/Resource/Internationalization.cs (1)
Flow.Launcher/PublicAPIInstance.cs (2)
  • LogError (216-217)
  • LogException (219-220)
Flow.Launcher/PublicAPIInstance.cs (2)
Flow.Launcher.Infrastructure/Stopwatch.cs (1)
  • Stopwatch (8-59)
Flow.Launcher.Infrastructure/Logger/Log.cs (4)
  • Debug (204-207)
  • Debug (210-213)
  • Info (215-218)
  • Info (221-224)
Flow.Launcher.Core/Resource/Theme.cs (2)
Flow.Launcher/PublicAPIInstance.cs (3)
  • LogError (216-217)
  • LogException (219-220)
  • LogWarn (213-214)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (3)
  • LogError (266-266)
  • LogException (272-272)
  • LogWarn (261-261)
Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (5)
Flow.Launcher.Infrastructure/Http/Http.cs (2)
  • Http (15-217)
  • Http (23-32)
Flow.Launcher.Core/Plugin/PluginConfig.cs (2)
  • List (25-65)
  • List (67-103)
Flow.Launcher.Core/Plugin/PluginManager.cs (1)
  • List (352-379)
Flow.Launcher.Core/Resource/Theme.cs (1)
  • List (396-409)
Plugins/Flow.Launcher.Plugin.PluginsManager/Utilities.cs (1)
  • UserPlugin (62-80)
Flow.Launcher.Infrastructure/Stopwatch.cs (1)
Flow.Launcher.Infrastructure/Logger/Log.cs (6)
  • Debug (204-207)
  • Debug (210-213)
  • Log (13-230)
  • Log (19-64)
  • Info (215-218)
  • Info (221-224)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
🔇 Additional comments (143)
Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs (2)

12-13: Good practice: Added class name constant for consistent logging.

Using a constant for the class name provides consistency and easier maintenance across logging calls.


49-49: Improved logging with API-based approach.

Replaced direct logging with dependency injection-based logging using IoC container. This aligns with the PR objective of standardizing logging across the application.

However, I don't see changes that specifically address the PR objective of "Ignore Plugin Source HTTP Exception". The code still catches and logs all exceptions without special handling for HTTP-specific exceptions.

Is there a specific reason why HTTP exceptions aren't being handled differently here, given the PR objective? Or is this implemented elsewhere?

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (2)

18-18: Good addition of the ClassName field for better logging maintainability.

Adding a static readonly field for the class name is a good practice that centralizes the class identifier for logging, making future refactoring easier.


474-474: LGTM: Improved logging with ClassName field reference.

This change uses the centralized ClassName field for logging exceptions, which is consistent with the PR's goal of standardizing logging practices.

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs (3)

8-8: Good addition of Microsoft.VisualStudio.Threading namespace.

This namespace is required for using the JoinableTaskFactory which enables non-blocking asynchronous operations.


31-31: Good addition of JoinableTaskFactory property.

Adding the JTF property with a new JoinableTaskContext enables asynchronous execution of potentially blocking operations, which is important for maintaining UI responsiveness.


37-37:

❓ Verification inconclusive

Improved async handling for package installation.

Replacing the direct call to DroplexPackage.Drop with JTF.Run prevents blocking the UI thread, which is important for maintaining application responsiveness during environment installation.

This change ensures consistency with similar implementations in TypeScriptEnvironment.cs and PythonEnvironment.cs. Consider adding error handling here to catch any exceptions during the asynchronous operation:


🏁 Script executed:

#!/bin/bash
# Check for error handling in other environment classes
rg -A 5 "JTF.Run" --glob "Flow.Launcher.Core/ExternalPlugins/Environments/*.cs"

Length of output: 2126


Async handling is improved, but consider adding error handling for robustness.
Replacing the direct call with JTF.Run(() => DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath)); prevents UI thread blocking, which is great. However, note that similar implementations in PythonEnvironment.cs and TypeScriptEnvironment.cs also lack error handling. It’s advisable to wrap the asynchronous call in a try/catch block to capture any exceptions that may occur, ensuring that installation failures are logged or handled gracefully.

  • File: Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs (around line 37)
  • Suggestion: Consider updating the code to something like:
    JTF.Run(() => {
        try {
            DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath);
        } catch (Exception ex) {
            // TODO: handle error (e.g., log the exception)
        }
    });
Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs (3)

13-13: Good addition of the ClassName field for better logging maintainability.

Adding a static readonly field for the class name is a good practice that centralizes the class identifier for logging, making future refactoring easier.


38-38: LGTM: Improved exception logging with ClassName field reference.

This change uses the centralized ClassName field for logging HTTP request exceptions, which is consistent with the PR's goal of standardizing logging practices.


43-43: LGTM: Improved JSON exception logging with ClassName field reference.

This change uses the centralized ClassName field for logging JSON parsing exceptions, which is consistent with the PR's goal of standardizing logging practices.

Flow.Launcher/SettingWindow.xaml.cs (1)

49-49: Updated to use static API instance instead of injected field.

This change aligns with the PR's objective of standardizing access to API services by using the static App.API property instead of an injected _api field, maintaining functionality while improving consistency across the codebase.

Flow.Launcher.Core/Resource/Theme.cs (7)

27-28: Good addition of a consistent class identifier for logging.

Adding the ClassName variable provides better maintainability and consistency for logging across the codebase.


77-77: Improved logging with contextual information.

Replacing direct Log.Error calls with API-based logging that includes class context enhances log traceability.


96-97: Enhanced exception logging with class context.

The refactored logging method properly includes the class name, providing better context for troubleshooting.


139-140: Consistent logging approach applied to exception handling.

The change maintains the same error handling logic while improving the logging implementation.


391-392: Standardized warning logging with class context.

Using the class variable instead of a hardcoded string improves maintainability.


444-445: Consistent error logging in exception handlers.

The approach is consistent with the PR's objective to standardize logging across the application.


454-455: Standardized error logging in XamlParseException handler.

This change completes the consistent logging approach throughout the file.

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs (2)

18-19: Good addition of class identifier for consistent logging.

Using a static readonly field for the class name enhances maintainability and follows the standardized logging approach being implemented across the codebase.


226-226: Improved exception logging with class context.

Replacing the hardcoded class name with the ClassName variable improves maintainability while keeping the same error handling logic.

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs (3)

13-14: Good addition of class identifier for consistent logging.

Adding the ClassName variable aligns with the standardized logging approach being implemented across the codebase.


32-33: Enhanced exception logging for HTTP requests.

The change improves maintainability while maintaining the same error handling logic for HTTP request exceptions.


37-38: Consistent approach to exception logging for JSON parsing.

The change maintains the error handling logic while improving the logging implementation.

Flow.Launcher/MessageBoxEx.xaml.cs (2)

12-13: Good addition of class identifier for consistent logging.

Adding the ClassName variable aligns with the standardized logging approach being implemented across the codebase.


62-63: Improved error logging with API-based approach.

Replacing direct Log.Error calls with App.API.LogError provides better context through the class name and aligns with the PR's objective to standardize logging.

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/DuckDuckGo.cs (3)

13-14: Good refactoring for improved logging context.

Adding a static ClassName variable improves maintainability by centralizing the class name reference used in logging. Using nameof(DuckDuckGo) ensures the variable automatically updates if the class is renamed.


39-39: LGTM!

Updating the logging to use the ClassName variable provides consistent context in logs.


44-44: LGTM!

Similarly, using ClassName here ensures consistent class naming in logs.

Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs (2)

64-64: LGTM!

The log statement now uses the centralized ClassName variable for context.


74-74: LGTM!

This log statement now also uses the ClassName variable for consistency.

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs (3)

14-14: Good refactoring for improved logging context.

Adding a static ClassName variable improves maintainability by centralizing the class name reference used in logging. Using nameof(Baidu) ensures the variable automatically updates if the class is renamed.


29-29: LGTM!

Updating the logging to use the ClassName variable provides consistent context in logs.


44-44: LGTM!

Similarly, using ClassName here ensures consistent class naming in logs.

Flow.Launcher/Helper/HotKeyMapper.cs (4)

15-15: Good refactoring for improved logging context.

Adding a static ClassName variable improves maintainability by centralizing the class name reference used in logging. Using nameof(HotKeyMapper) ensures the variable automatically updates if the class is renamed.


56-60: Improved logging through API abstraction.

Good change from direct Log.Error calls to using the abstracted App.API.LogError method. This is in line with the PR objective of standardizing logging practices across the application. The API approach provides more flexibility for future enhancements to logging.


81-85: LGTM!

Similarly, updating to use App.API.LogError with the ClassName variable provides consistent logging context.


107-111: LGTM!

Consistent with other changes, using App.API.LogError with the ClassName variable improves logging structure.

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs (3)

8-8: Added necessary import for JoinableTaskFactory.

The import for Microsoft.VisualStudio.Threading is required for the JoinableTaskFactory implementation.


31-32: Good addition of the JoinableTaskFactory property.

This property follows the pattern implemented in other environment classes (PythonEnvironment and TypeScriptV2Environment) and facilitates asynchronous execution.


37-37:

✅ Verification successful

Improved responsiveness by making installation non-blocking.

Changed from a blocking call to using JTF.Run(), which improves application responsiveness during potentially long-running operations like package installations.

Verify that subsequent operations don't rely on the installation being completed:


🏁 Script executed:

#!/bin/bash
# Check if code uses any awaits or expects the installation to be completed
rg -A 5 -B 5 "InstallEnvironment" --type csharp

Length of output: 7923


Non-Blocking Installation Confirmed

The use of JTF.Run() in Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs now properly triggers the package installation asynchronously, thereby improving responsiveness. Our grep check across the codebase confirms that subsequent operations invoking InstallEnvironment() do not await or depend on its completion. No additional changes are required.

Flow.Launcher/ProgressBoxEx.xaml.cs (2)

10-11: Good addition of class name constant for logging.

Using nameof(ProgressBoxEx) ensures that if the class name changes during refactoring, this reference will be automatically updated, improving maintainability.


51-51: Standardized logging approach.

Changed from using direct Log.Error call to App.API.LogError, which aligns with the PR objective of standardizing logging across the application. Including the class name as context improves traceability.

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs (2)

16-17: Good addition of class name constant for logging.

Using nameof(AbstractPluginEnvironment) ensures that if the class name changes during refactoring, this reference will be automatically updated, improving maintainability.


124-126: Standardized logging approach.

Changed from using direct Log.Error call to API.LogError, which aligns with the PR objective of standardizing logging across the application. Including the class name as context improves traceability while preserving the same error message content.

Flow.Launcher.Core/Plugin/PluginConfig.cs (9)

8-8: Added dependency for IoC container.

This import adds the dependency injection capability needed for the API service retrieval.


14-14: Good practice: Added class name constant for logging.

Using a constant for the class name in logs improves consistency and maintainability.


16-18: Implemented lazy loading for API service.

The comment correctly explains why static constructor initialization is avoided. The lazy initialization pattern ensures the API instance is only created when needed.


41-41: Replaced direct Log call with API-based logging.

Changed from using static Log.Exception to API.LogException with the new class name constant.


58-62: Refactored warning logging to use API.

Updated to use API.LogWarn with the class name constant for consistent logging approach.


110-110: Refactored error logging to use API.

Updated to use API.LogError with the class name constant.


126-126: Refactored exception logging to use API.

Updated to use API.LogException with the class name constant.


132-132: Refactored error logging to use API.

Updated to use API.LogError with the class name constant.


138-138: Refactored error logging to use API.

Updated to use API.LogError with the class name constant.

Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs (2)

3-3: Updated import to include Logger namespace.

Added explicit reference to the Logger namespace for using the Log class directly.


30-30:

✅ Verification successful

Changed from API-based logging to direct Log calls.

This change appears to be opposite to the pattern seen in other files. In most other files, direct Log calls are being replaced with API.Log calls, while here it's the reverse.


🏁 Script executed:

#!/bin/bash
# Check if there's a pattern of changing API-based logging to direct Log calls in infrastructure files

echo "Checking if this pattern is consistent across infrastructure files..."
rg -A 1 "Log\.Exception" --glob="Flow.Launcher.Infrastructure/**/*.cs"
echo "---------------"
echo "Checking if there's a transition from API.LogException to Log.Exception..."
rg -A 1 -B 1 "API\.LogException" --glob="Flow.Launcher.Infrastructure/**/*.cs"

Length of output: 3617


Logging Pattern Consistency Verified

After checking the codebase, all infrastructure files (including the ones in Http, Storage, and Image folders) consistently use direct Log.Exception calls. There are no instances of API.LogException, so the change in FlowLauncherJsonStorage.cs follows the established pattern. No modifications are needed here.

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs (2)

12-12: Good practice: Added class name constant for logging.

Using a constant for the class name in logs improves consistency and maintainability across the codebase.


80-80: Updated logging to use class name constant.

Updated to use the new ClassName constant instead of hardcoding the class name in logging calls.

Flow.Launcher.Core/Plugin/PluginManager.cs (6)

216-217: Refactored info logging to use API.

Updated from Log.Info to API.LogInfo to maintain consistent logging approach.


221-221: Refactored exception logging to use API.

Updated from Log.Exception to API.LogException for consistent logging approach.


372-374: Refactored exception logging to use API.

Updated from Log.Exception to API.LogException with improved formatting for better readability.


565-565: Refactored exception logging to use API.

Updated from Log.Exception to API.LogException.


610-610: Refactored exception logging to use API.

Updated from Log.Exception to API.LogException.


626-626: Refactored exception logging to use API.

Updated from Log.Exception to API.LogException.

Flow.Launcher/Helper/AutoStartup.cs (7)

14-14: LGTM: Good addition of a standardized way to reference class name.

Adding a static readonly variable for the class name is a good practice for maintainability and consistency in logging statements.


39-39: LGTM: Good switch to API-based logging.

Switched from direct Log.Error to App.API.LogError, which matches the PR objective of standardizing logging across the application.


66-66: LGTM: Consistent use of API-based logging.

Consistently applying the logging improvement pattern here.


117-117: LGTM: Maintaining consistency in error logging.

All error logging has been standardized to use the App.API.LogError method.


138-138: LGTM: Consistent logging pattern applied.

Continues the pattern of standardized logging with class name context.


166-166: LGTM: Standardized error logging.

Standardized error logging with proper context.


181-181: LGTM: Final logging standardization applied.

All logging calls now consistently use the API-based approach.

Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs (2)

10-10: LGTM: Enabling nullable reference types.

Enabling nullable reference types improves type safety by helping detect possible null reference exceptions at compile time.


16-16: LGTM: Improved field declaration.

The change from private static JobObject _jobObject = new JobObject(); to private static readonly JobObject _jobObject = new(); has two improvements:

  1. Added readonly modifier to prevent accidental reassignment
  2. Using the modern C# target-typed new expression for cleaner syntax
Flow.Launcher.Infrastructure/Image/ImageLoader.cs (6)

10-10: LGTM: Simplified dependency in Infrastructure project.

Added direct import of the Logger namespace instead of relying on IPublicAPI for logging functions, which aligns with the PR objective of having the Infrastructure project use static logging.


56-63: LGTM: Switched from API-based to direct logging.

Replaced API.StopwatchLogInfoAsync with Stopwatch.InfoAsync and API.LogInfo with Log.Info, which aligns with the PR objective of standardizing logging for the Infrastructure project to use static logging.


79-79: LGTM: Consistent direct logging in Infrastructure.

Changed from API-based exception logging to direct static logging, maintaining consistency in the Infrastructure project.


174-175: LGTM: Consistent exception logging.

Applying the same logging pattern consistently throughout the class.


241-241: LGTM: Consistently using direct logging.

Maintained consistency in the error logging approach.


265-265: LGTM: Final consistent logging change.

All logging calls consistently use direct static logging now.

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (2)

13-13: LGTM: Good addition of class name constant.

Adding a static readonly variable for the class name is a good practice for maintainability and consistency in logging statements.


68-68: LGTM: Switched to API-based logging.

Replaced direct Log.Exception with App.API.LogException, which aligns with the PR objective of standardizing non-Infrastructure projects to use API-based logging.

Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs (3)

3-3: Updated import to use infrastructure Logger.

This import change aligns with the PR objective to standardize logging across the application, shifting from API-based logging to the static Log class.


10-10: Added class identifier for consistent logging.

A static class name field has been added to provide a consistent identifier for logging, improving traceability of log entries.


28-28: Replaced API-based logging with static Log class.

The code now uses Log.Exception with the ClassName parameter instead of the previous API.LogException. This change is consistent with the PR objective to standardize logging practices.

Also applies to: 40-40

Flow.Launcher.Core/Configuration/Portable.cs (3)

1-12: Updated and reorganized imports.

The imports have been reorganized and updated to include necessary dependencies while removing unused ones.


18-19: Added class identifier for consistent logging.

A static class name field has been added using nameof(Portable) to provide a consistent identifier for logging, improving traceability of log entries.


55-55: Switched to API-based logging with class identifier.

Changed from using Log.Exception to API.LogException with the ClassName parameter. While this moves in the opposite direction compared to PluginBinaryStorage.cs (which moved from API to static logging), it maintains consistency within this class as it already has access to the API instance.

Also applies to: 79-79

Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (2)

15-16: Added class identifier for consistent logging.

A static class name field has been added using nameof(ProcessHelper) to provide a consistent identifier for logging, improving code maintainability.


136-136: Updated logging to use class identifier variable.

The code now uses the ClassName variable instead of an inline nameof(ProcessHelper) expression, improving consistency and maintainability.

Flow.Launcher/Helper/WallpaperPathRetrieval.cs (2)

15-16: Added class identifier for consistent logging.

A static class name field has been added using nameof(WallpaperPathRetrieval) to provide a consistent identifier for logging, improving code maintainability.


34-34: Updated multiple logging calls to use class identifier variable.

All logging statements now use the ClassName variable instead of inline nameof(WallpaperPathRetrieval) expressions. This improves consistency and maintainability by centralizing the class name reference to a single location.

Also applies to: 59-59, 100-100, 118-118

Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs (2)

3-3: Updated import for logging.

The import statement has been added to access the Logger functionality directly, which aligns with the PR's goal of standardizing logging across the application.


40-40: Improved exception logging with consistent class name reference.

The exception logging has been updated to use Log.Exception(ClassName, ...) which provides better context in logs by including the class name. This change aligns with the PR objective to standardize logging across the application by moving from API-based logging to direct Log class usage.

Also applies to: 52-52

Flow.Launcher/ViewModel/ResultViewModel.cs (1)

235-237: Improved exception logging through API.

The exception logging has been updated to use App.API.LogException with the class name parameter, which provides better context in logs. This change aligns with the PR objective to standardize logging across the application.

Flow.Launcher/ReportWindow.xaml.cs (3)

12-12: Added import for DataLocation.

The import statement has been added to access the DataLocation functionality, which is now used to retrieve the log directory path.


18-18: Added class name constant for logging.

A static readonly string field ClassName has been added to store the class name, which is a good practice for consistent logging across the application.


43-43: Updated log directory source.

Changed from using Log.CurrentLogDirectory to DataLocation.VersionLogDirectory for retrieving the log directory path. This centralizes the log directory path management in the DataLocation class.

Flow.Launcher.Core/Updater.cs (3)

26-26: Added class name constant for logging.

A static readonly string field ClassName has been added, which improves logging consistency by providing context to log messages.


55-55: Standardized info logging through API.

Updated logging calls to use _api.LogInfo(ClassName, ...) instead of direct logging, which aligns with the PR objective to standardize logging practices.

Also applies to: 88-88


97-104: Improved exception handling and logging.

The exception handling has been updated with:

  1. Modern C# pattern matching for exception types using the or keyword for better readability
  2. Standardized logging through _api.LogException(ClassName, ...)
  3. Better error message for network-related exceptions

These changes align with the PR objective to improve error handling for HTTP exceptions while standardizing logging.

Flow.Launcher/App.xaml.cs (7)

151-152: Improved logging with standardized context pattern.

The logging has been updated to use API.LogInfo with a consistent ClassName variable instead of directly using Log.Info with hardcoded strings. This matches the PR objective of standardizing the logging mechanism across the application.


179-179: Standardized logging format for dependencies info.

Using API.LogInfo with ClassName for logging dependencies information ensures consistent logging patterns throughout the application.


195-195: Standardized logging for end of startup process.

This follows the same pattern of using API.LogInfo with ClassName for consistency in logs.


253-253: Standardized logging for process exit events.

Updated exit event logging to use API.LogInfo with ClassName for better consistency and context in logs.


259-259: Standardized logging for application exit events.

Updated to use the new logging pattern consistent with other changes.


265-265: Standardized logging for session ending events.

Updated to use the new logging pattern consistent with other changes.


329-329: Standardized logging for application disposal process.

Updated both the beginning and end of the disposal process logs to use the new API.LogInfo with ClassName pattern.

Also applies to: 339-339

Flow.Launcher/ViewModel/MainViewModel.cs (4)

32-33: Added class identifier for consistent logging.

Added a private static readonly field ClassName to store the class name for use in logging calls. This improves maintainability by centralizing the class name reference and ensuring consistency across all log messages.


217-217: Updated error logging to use API with class context.

Changed from direct Log.Error to App.API.LogError with the ClassName variable to provide better context in logs for unexpected result view updates.


261-261: Updated queue error logging to use API with class context.

Changed direct logging to use App.API.LogError with ClassName for more consistent error logging.


351-353: Updated exception logging to use API with class context.

Changed from direct exception logging to using App.API.LogException with ClassName and improved the error message format for better context when shortcut expansion fails.

Flow.Launcher.Core/Resource/Internationalization.cs (6)

19-24: Implemented lazy API initialization for logging.

This change:

  1. Adds a private static readonly field ClassName for consistent logging
  2. Uses lazy initialization for the API to prevent circular dependencies
  3. Includes a detailed comment explaining why API shouldn't be initialized in the static constructor

This is a good approach to manage dependencies while ensuring consistent logging.


88-88: Updated plugin path error logging to use API.

Changed from direct logging to use API.LogError with ClassName for more consistent error reporting when plugin paths cannot be found.


158-158: Updated language code error logging to use API.

Changed from direct logging to use API.LogError with ClassName for more consistent error reporting when language codes cannot be found.


256-256: Updated translation key error logging to use API.

Changed from direct logging to use API.LogError with ClassName for more consistent error reporting when translation keys cannot be found.


274-274: Updated plugin exception logging to use API.

Changed from direct exception logging to use API.LogException with ClassName for more consistent error reporting when plugin translations fail.


290-290: Updated language path error logging to use API.

Changed from direct logging to use API.LogError with ClassName for more consistent error reporting when language paths cannot be found.

Also applies to: 298-298

Flow.Launcher.Infrastructure/Http/Http.cs (6)

1-12: Improved code organization and readability.

The using directives have been reorganized for better clarity, and unnecessary empty lines have been removed to improve code readability.


17-18: Added class identifier for consistent logging.

Added a static field ClassName for use in logging calls throughout the class, improving the consistency of log messages.


21-21: Improved HttpClient declaration.

Changed the HttpClient declaration to:

  1. Make it readonly to prevent accidental reassignment
  2. Use the C# 9.0 target-typed new expression syntax (new())

This is a good improvement for both safety and modern C# practices.


38-38: Simplified property getter.

Changed the property getter from a block body to an expression-bodied member, making the code more concise without changing functionality.


76-76: Updated exception creation in switch expression.

Changed the ArgumentOutOfRangeException to include a null argument. This is a minor change that aligns with .NET guidelines for creating exceptions.


82-82: Updated logging to use consistent class context.

All logging calls now use the ClassName variable instead of hardcoded strings. This improves maintainability by ensuring all logs from this class have consistent identifiers.

Also applies to: 138-138, 151-151, 163-163, 195-195, 206-206

Flow.Launcher/PublicAPIInstance.cs (4)

437-438: Implementation updated to use the new API format.

The StopwatchLogDebug method now correctly passes parameters to the updated Stopwatch.Debug method, matching its new signature that accepts class name and method name as separate parameters rather than a formatted string.


440-441: Implementation updated to use the new API format.

The StopwatchLogDebugAsync method now correctly passes parameters to the updated Stopwatch.DebugAsync method, aligning with the new parameter structure.


443-444: Implementation updated to use renamed method and new parameter format.

The StopwatchLogInfo method now correctly calls Stopwatch.Info (previously called Normal) with the new parameter structure, improving consistency in the logging API.


446-447: Implementation updated to use renamed method and new parameter format.

The StopwatchLogInfoAsync method now correctly calls Stopwatch.InfoAsync (previously called NormalAsync) with the new parameter structure, completing the standardization of logging method calls.

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (6)

19-22: Good implementation of lazy initialization for API service.

The static API property with lazy initialization through dependency injection is a good pattern that avoids circular dependencies. The comment explains why API isn't initialized in the static constructor, which is helpful for future maintainers.


23-23: Added consistent class name variable for logging.

Adding a static readonly ClassName field follows good practice for standardized logging across the application, making the class name consistent throughout all log messages.


29-29: Improved field declaration with readonly modifier and target-typed new.

The field is now correctly marked as readonly and uses the more concise target-typed new operator, improving both thread safety and readability.


44-44: Updated logging to use API interface.

Logging now correctly uses the API interface with the standardized ClassName variable, which aligns with the PR objective to shift from static Log class to API-based logging.


50-75: Improved HTTP response handling with comprehensive status code checks.

The HTTP response handling has been significantly improved with specific handling for different status codes:

  • OK (200): Deserializes content, updates ETag, and logs success
  • NotModified (304): Logs the unchanged status and returns cached plugins
  • Other status codes: Logs a warning and returns cached plugins

This enhanced error handling ensures more reliable operation and better diagnostic information.


76-87: Enhanced exception handling with specific connection-related error messages.

This exception handling block now correctly:

  1. Specifically identifies network-related exceptions (HttpRequestException, WebException, SocketException, TimeoutException)
  2. Provides a more helpful error message for connection issues
  3. Logs general exceptions separately
  4. Always returns the cached plugins list to maintain consistent return type

This implementation aligns with the PR objective to "Ignore Plugin Source HTTP Exception" while still providing informative logs.

Flow.Launcher.Infrastructure/Stopwatch.cs (5)

2-2: Added required namespace for CallerMemberName attribute.

The System.Runtime.CompilerServices namespace has been correctly added to support the CallerMemberName attribute used in the updated method signatures.


13-21: Updated Debug method signature and implementation to include class and method context.

The Debug method signature has been enhanced to:

  1. Accept className and methodName parameters
  2. Use CallerMemberName attribute for automatic method name capture
  3. Pass these parameters to Log.Debug for improved logging context

This change improves the logging by providing more structured information about where the timed action is occurring.


27-35: Updated DebugAsync method signature and implementation with consistent context parameters.

Similar to the synchronous version, the DebugAsync method now accepts and properly uses className and methodName parameters, ensuring consistent logging across both synchronous and asynchronous operations.


38-47: Renamed Normal method to Info with updated signature for better clarity.

The method has been appropriately renamed from Normal to Info, which better reflects the logging level it uses (Log.Info). The signature has also been updated to include className and methodName parameters consistent with the Debug methods.


49-57: Renamed NormalAsync method to InfoAsync with updated signature for consistent naming.

The asynchronous counterpart has been renamed from NormalAsync to InfoAsync, maintaining naming consistency with the synchronous version while adding the same contextual parameters for improved logging.

Plugins/Flow.Launcher.Plugin.WindowsSettings/Log.cs (1)

14-14: Improved method spacing enhances code readability

The addition of blank lines between method definitions improves code readability and follows common coding conventions for C#.

Also applies to: 19-19

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs (3)

8-8: Added Microsoft.VisualStudio.Threading namespace for JoinableTaskFactory

This namespace addition supports the new asynchronous execution implementation.


34-35: Added JoinableTaskFactory for improved asynchronous execution

Good introduction of JoinableTaskFactory to replace blocking calls with asynchronous execution. This helps maintain UI responsiveness during potentially long-running operations.


42-42: Replaced blocking call with JTF.Run for asynchronous execution

The change from a likely direct await to JTF.Run() prevents potential UI freezing while maintaining synchronous behavior from the caller's perspective.

Flow.Launcher/Notification.cs (2)

11-12: Added class name constant for improved logging context

Using nameof(Notification) for the class name is a good practice as it avoids hardcoded strings and ensures the class name stays in sync with any refactoring.


55-55: Standardized exception logging with API interface

Replaced direct logging calls with App.API.LogException and included the class name for better context in logs. This change aligns with the PR objective to standardize logging practices across the application.

Also applies to: 60-60

@Jack251970 Jack251970 requested a review from Copilot April 13, 2025 10:14
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 49 out of 49 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

Flow.Launcher.Core/Plugin/PluginManager.cs:216

  • The variable 'ClassName' is referenced in the logging call without being declared in this file. Define it (e.g. 'private static readonly string ClassName = nameof(PluginManager);') to avoid runtime issues.
API.LogInfo(ClassName, $"Total init cost for <{pair.Metadata.Name}> is <{pair.Metadata.InitTime}ms>");

This comment has been minimized.

@Jack251970 Jack251970 added Code Quality Dev branch only An issue or fix for the Dev branch build labels Apr 13, 2025
@Jack251970 Jack251970 added this to the 1.20.0 milestone Apr 13, 2025
Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
ℹ️ candidate-pattern 1
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

Pattern suggestions ✂️ (1)

You could add these patterns to .github/actions/spelling/patterns.txt:

# Automatically suggested patterns

# hit-count: 3 file-count: 1
# Non-English
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

@Jack251970 Jack251970 requested a review from Copilot April 13, 2025 10:16
Copy link

gitstream-cm bot commented Apr 13, 2025

🥷 Code experts: no user but you matched threshold 10

Jack251970, jjw24 have most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/Configuration/Portable.cs

Knowledge based on git-blame:
jjw24: 71%
Jack251970: 16%

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs

Knowledge based on git-blame:
Jack251970: 1%

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Knowledge based on git-blame:
jjw24: 41%
Jack251970: 28%

Flow.Launcher.Core/ExternalPlugins/Environments/JavaScriptEnvironment.cs

Knowledge based on git-blame:
jjw24: 100%

Flow.Launcher.Core/ExternalPlugins/Environments/JavaScriptV2Environment.cs

Knowledge based on git-blame:

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Knowledge based on git-blame:
jjw24: 60%
Jack251970: 17%

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Knowledge based on git-blame:
jjw24: 58%
Jack251970: 19%

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs

Knowledge based on git-blame:
Jack251970: 19%

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Knowledge based on git-blame:
Jack251970: 30%

Flow.Launcher.Core/Plugin/PluginConfig.cs

Knowledge based on git-blame:
Jack251970: 2%
jjw24: 2%

Flow.Launcher.Core/Plugin/PluginManager.cs

Knowledge based on git-blame:
Jack251970: 26%
jjw24: 3%

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Knowledge based on git-blame:
Jack251970: 18%
jjw24: 15%

Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs

Knowledge based on git-blame:

Flow.Launcher.Core/Resource/Internationalization.cs

Knowledge based on git-blame:
Jack251970: 35%
jjw24: 8%

Flow.Launcher.Core/Resource/Theme.cs

Knowledge based on git-blame:
Jack251970: 65%
jjw24: 2%

Flow.Launcher.Core/Updater.cs

Knowledge based on git-blame:
Jack251970: 24%
jjw24: 10%

Flow.Launcher.Infrastructure/Http/Http.cs

Knowledge based on git-blame:
Jack251970: 18%
jjw24: 2%

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Knowledge based on git-blame:
Jack251970: 26%
jjw24: 4%

Flow.Launcher.Infrastructure/Logger/Log.cs

Knowledge based on git-blame:
Jack251970: 14%

Flow.Launcher.Infrastructure/Stopwatch.cs

Knowledge based on git-blame:
jjw24: 3%

Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs

Knowledge based on git-blame:
Jack251970: 57%
jjw24: 2%

Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs

Knowledge based on git-blame:
Jack251970: 75%
jjw24: 6%

Flow.Launcher.Infrastructure/Storage/JsonStorage.cs

Knowledge based on git-blame:
jjw24: 11%
Jack251970: 7%

Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs

Knowledge based on git-blame:
Jack251970: 100%

Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs

Knowledge based on git-blame:
Jack251970: 67%
jjw24: 7%

Flow.Launcher/App.xaml.cs

Knowledge based on git-blame:
Jack251970: 64%
jjw24: 4%

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs

Knowledge based on git-blame:
jjw24: 21%

Flow.Launcher/Helper/AutoStartup.cs

Knowledge based on git-blame:
Jack251970: 73%

Flow.Launcher/Helper/HotKeyMapper.cs

Knowledge based on git-blame:
jjw24: 36%
Jack251970: 9%

Flow.Launcher/Helper/WallpaperPathRetrieval.cs

Knowledge based on git-blame:
Jack251970: 56%

Flow.Launcher/MessageBoxEx.xaml.cs

Knowledge based on git-blame:
Jack251970: 61%

Flow.Launcher/Msg.xaml.cs

Knowledge based on git-blame:
Jack251970: 14%
jjw24: 8%

Flow.Launcher/Notification.cs

Knowledge based on git-blame:
Jack251970: 3%

Flow.Launcher/ProgressBoxEx.xaml.cs

Knowledge based on git-blame:
Jack251970: 100%

Flow.Launcher/PublicAPIInstance.cs

Knowledge based on git-blame:
Jack251970: 44%
jjw24: 6%

Flow.Launcher/ReportWindow.xaml.cs

Knowledge based on git-blame:
Jack251970: 26%
jjw24: 6%

Flow.Launcher/SettingWindow.xaml.cs

Knowledge based on git-blame:
Jack251970: 19%

Flow.Launcher/ViewModel/MainViewModel.cs

Knowledge based on git-blame:
Jack251970: 29%
jjw24: 1%

Flow.Launcher/ViewModel/ResultViewModel.cs

Knowledge based on git-blame:
Jack251970: 30%
jjw24: 3%

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs

Knowledge based on git-blame:
Jack251970: 11%
jjw24: 11%

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Knowledge based on git-blame:
jjw24: 54%
Jack251970: 3%

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs

Knowledge based on git-blame:
jjw24: 51%
Jack251970: 3%

Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs

Knowledge based on git-blame:
Jack251970: 44%

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Knowledge based on git-blame:
Jack251970: 59%
jjw24: 6%

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs

Knowledge based on git-blame:
Jack251970: 5%
jjw24: 2%

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs

Knowledge based on git-blame:
Jack251970: 10%

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/DuckDuckGo.cs

Knowledge based on git-blame:
Jack251970: 6%

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs

Knowledge based on git-blame:
Jack251970: 7%
jjw24: 4%

Plugins/Flow.Launcher.Plugin.WindowsSettings/Log.cs

Knowledge based on git-blame:

To learn more about /:\ gitStream - Visit our Docs

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 49 out of 49 changed files in this pull request and generated no comments.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20d2661 and 3fab9da.

📒 Files selected for processing (4)
  • Flow.Launcher.Core/Plugin/PluginsLoader.cs (1 hunks)
  • Flow.Launcher.Infrastructure/Logger/Log.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (6 hunks)
  • Flow.Launcher/ViewModel/ResultViewModel.cs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Flow.Launcher/ViewModel/ResultViewModel.cs
  • Flow.Launcher/ViewModel/MainViewModel.cs
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (3)
Flow.Launcher.Infrastructure/Logger/Log.cs (3)

131-138: Improved exception handling separation between debug and release builds.

The explicit preprocessor directive for the ExceptionInternal method ensures that exceptions are handled differently in debug versus release builds. In debug mode, exceptions are rethrown for immediate debugging, while in release builds they're properly logged but not rethrown.

This change is part of a broader refactoring to improve logging across the application by requiring contextual information (className, methodName) for all log entries, which aligns with the PR objective to standardize logging practices.


97-107: Standardized logging with improved context information.

The removal of simplified logging methods (those taking only message parameters) enforces a more structured approach to logging throughout the codebase. Now all logging must include:

  1. Class name - providing source context
  2. Message - the actual log information
  3. Method name - automatically captured using CallerMemberName

This change aligns with modern logging best practices where contextual information is crucial for effective troubleshooting. The PR objective mentioned shifting from direct static Log class usage to an API-based approach, and these changes support that transition by standardizing the logging interface.

Also applies to: 140-167


1-175: Well-structured logging system with good separation of concerns.

The logging implementation follows good practices:

  1. Validates inputs with helpful error messages
  2. Captures contextual information (class and method names)
  3. Uses different handling strategies for debug vs release builds
  4. Implements async file target for better performance
  5. Properly demystifies exceptions for clearer stack traces

Note that while the PR objectives mention "Ignore Plugin Source HTTP Exception," that change is not present in this file and must be implemented elsewhere in the codebase.

catch (Exception e) when (assembly == null)
{
Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for the plugin: {metadata.Name}", e);
Log.Exception(ClassName, $"Couldn't load assembly for the plugin: {metadata.Name}", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use API.LogException instead of Log.Exception for consistency.

The PR's objective is to standardize logging by using API-based methods rather than static Log calls. Though the ClassName and API variables are properly defined at the top of the file, this logging statement still uses the static method.

Modify the logging call as follows:

-Log.Exception(ClassName, $"Couldn't load assembly for the plugin: {metadata.Name}", e);
+API.LogException(ClassName, $"Couldn't load assembly for the plugin: {metadata.Name}", e);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Log.Exception(ClassName, $"Couldn't load assembly for the plugin: {metadata.Name}", e);
API.LogException(ClassName, $"Couldn't load assembly for the plugin: {metadata.Name}", e);

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 49 out of 49 changed files in this pull request and generated no comments.

@Jack251970 Jack251970 requested a review from onesounds April 13, 2025 10:20
@Jack251970
Copy link
Member Author

Look good to me and already tested.

@Jack251970 Jack251970 enabled auto-merge April 13, 2025 10:20
@Jack251970 Jack251970 merged commit 9dd5f06 into dev Apr 13, 2025
12 checks passed
@Jack251970 Jack251970 deleted the ignore_plugin_source_http_exception branch April 13, 2025 11:06
@jjw24 jjw24 changed the title Improve log & Ignore plugin source http exception Unify logging for core projects & Ignore plugin source http exception May 4, 2025
@jjw24 jjw24 added bug Something isn't working and removed Dev branch only An issue or fix for the Dev branch build labels May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Code Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants