From 4e4758677f2b533fb6ed107f948ff7d7a1ab2570 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 1 Mar 2025 19:21:09 +0800 Subject: [PATCH 01/18] Remove unneccessary CreateSettingPanel by introducing need check --- Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs | 7 ++++++- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 9 +++++++-- Flow.Launcher/ViewModel/PluginViewModel.cs | 8 ++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs index ed8f94bcf..7248c6259 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs @@ -34,7 +34,7 @@ namespace Flow.Launcher.Core.Plugin /// Represent the plugin that using JsonPRC /// every JsonRPC plugin should has its own plugin instance /// - internal abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable + public abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable { protected PluginInitContext Context; public const string JsonRPC = "JsonRPC"; @@ -157,6 +157,11 @@ namespace Flow.Launcher.Core.Plugin Settings?.Save(); } + public bool NeedCreateSettingPanel() + { + return Settings.NeedCreateSettingPanel(); + } + public Control CreateSettingPanel() { return Settings.CreateSettingPanel(); diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 2a4b22bf3..8412ba7e8 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -109,10 +109,15 @@ namespace Flow.Launcher.Core.Plugin _storage.Save(); } + public bool NeedCreateSettingPanel() + { + // If there are no settings or the settings configuration is empty, return null + return Settings != null && Configuration != null && Configuration.Body.Count != 0; + } + public Control CreateSettingPanel() { - if (Settings == null || Settings.Count == 0) - return null; + // No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true var settingWindow = new UserControl(); var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center }; diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs index 46f8e00a2..209a81395 100644 --- a/Flow.Launcher/ViewModel/PluginViewModel.cs +++ b/Flow.Launcher/ViewModel/PluginViewModel.cs @@ -90,13 +90,13 @@ namespace Flow.Launcher.ViewModel private Control _bottomPart2; public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null; - public bool HasSettingControl => PluginPair.Plugin is ISettingProvider settingProvider && settingProvider.CreateSettingPanel() != null; + public bool HasSettingControl => PluginPair.Plugin is ISettingProvider && (PluginPair.Plugin is not JsonRPCPluginBase jsonRPCPluginBase || jsonRPCPluginBase.NeedCreateSettingPanel()); public Control SettingControl => IsExpanded ? _settingControl - ??= PluginPair.Plugin is not ISettingProvider settingProvider - ? null - : settingProvider.CreateSettingPanel() + ??= HasSettingControl + ? ((ISettingProvider)PluginPair.Plugin).CreateSettingPanel() + : null : null; private ImageSource _image = ImageLoader.MissingImage; From 889f4cbfeb4959477c3c3db8bdaf66c527cb902e Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 4 Mar 2025 11:08:09 +0800 Subject: [PATCH 02/18] Fix null reference exception when checking source --- .../Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index f4c8a66da..4ceadec56 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -593,7 +593,10 @@ namespace Flow.Launcher.Plugin.PluginsManager var constructedUrlPart = string.Format("{0}/{1}/", acceptedSource, author); return url.StartsWith(acceptedSource) && - Context.API.GetAllPlugins().Any(x => x.Metadata.Website.StartsWith(constructedUrlPart)); + Context.API.GetAllPlugins().Any(x => + !string.IsNullOrEmpty(x.Metadata.Website) && + x.Metadata.Website.StartsWith(constructedUrlPart) + ); } internal async ValueTask> RequestInstallOrUpdateAsync(string search, CancellationToken token, From 719d30ebf0a09e54a46948a786caa6069303ca0e Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Thu, 6 Mar 2025 07:41:22 +0800 Subject: [PATCH 03/18] Use official Task Scheduler --- Flow.Launcher/Flow.Launcher.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 33d13614f..8f6e47bbb 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -104,7 +104,7 @@ - + From 69b7aeadeb09cebd6e576c4817e01fe324522af4 Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Thu, 6 Mar 2025 20:07:01 +0800 Subject: [PATCH 04/18] Update dependabot.yml --- .github/dependabot.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d9b39eb89..da4231f74 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,7 +8,8 @@ updates: - package-ecosystem: "nuget" # See documentation for possible values directory: "/" # Location of package manifests schedule: - interval: "weekly" + interval: "daily" + open-pull-requests-limit: 3 ignore: - dependency-name: "squirrel-windows" reviewers: From f2c30347a762f3a29b176d6730081be3d64e3e14 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Sat, 8 Mar 2025 12:24:47 +0600 Subject: [PATCH 05/18] Add new sponsor to README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 02ffc7932..6611f55dc 100644 --- a/README.md +++ b/README.md @@ -334,11 +334,14 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea Coderabbit Logo -
-
+
+
+ + +

From 8ca734ae065813062c119f78b8b8f2fb2d99f211 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 03:18:48 +0000 Subject: [PATCH 06/18] Bump FSharp.Core from 9.0.101 to 9.0.201 Bumps [FSharp.Core](https://github.com/dotnet/fsharp) from 9.0.101 to 9.0.201. - [Release notes](https://github.com/dotnet/fsharp/releases) - [Changelog](https://github.com/dotnet/fsharp/blob/main/release-notes.md) - [Commits](https://github.com/dotnet/fsharp/commits) --- updated-dependencies: - dependency-name: FSharp.Core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Flow.Launcher.Core/Flow.Launcher.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Flow.Launcher.Core.csproj b/Flow.Launcher.Core/Flow.Launcher.Core.csproj index df2f4d2cb..5201d051a 100644 --- a/Flow.Launcher.Core/Flow.Launcher.Core.csproj +++ b/Flow.Launcher.Core/Flow.Launcher.Core.csproj @@ -54,7 +54,7 @@ - + From 66457b1dfb729a9ebed6e933f26ef9a3ecaa2709 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 03:19:20 +0000 Subject: [PATCH 07/18] Bump MemoryPack from 1.21.3 to 1.21.4 Bumps [MemoryPack](https://github.com/Cysharp/MemoryPack) from 1.21.3 to 1.21.4. - [Release notes](https://github.com/Cysharp/MemoryPack/releases) - [Commits](https://github.com/Cysharp/MemoryPack/compare/1.21.3...1.21.4) --- updated-dependencies: - dependency-name: MemoryPack dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Infrastructure.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj index 5d8b26425..b91da7114 100644 --- a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj +++ b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj @@ -59,7 +59,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all From c1a80158e609a2573b484793ea1baa499c699404 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 07:24:13 +0000 Subject: [PATCH 08/18] Bump StreamJsonRpc from 2.20.20 to 2.21.10 Bumps [StreamJsonRpc](https://github.com/microsoft/vs-streamjsonrpc) from 2.20.20 to 2.21.10. - [Release notes](https://github.com/microsoft/vs-streamjsonrpc/releases) - [Commits](https://github.com/microsoft/vs-streamjsonrpc/commits) --- updated-dependencies: - dependency-name: StreamJsonRpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Flow.Launcher.Core/Flow.Launcher.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Flow.Launcher.Core.csproj b/Flow.Launcher.Core/Flow.Launcher.Core.csproj index 5201d051a..e9f199d00 100644 --- a/Flow.Launcher.Core/Flow.Launcher.Core.csproj +++ b/Flow.Launcher.Core/Flow.Launcher.Core.csproj @@ -58,7 +58,7 @@ - + From 65d42bf7c06aa26bb5e10c54e6cfb59e1519bc92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 07:25:00 +0000 Subject: [PATCH 09/18] Bump Microsoft.Data.Sqlite from 9.0.1 to 9.0.2 Bumps [Microsoft.Data.Sqlite](https://github.com/dotnet/efcore) from 9.0.1 to 9.0.2. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v9.0.1...v9.0.2) --- updated-dependencies: - dependency-name: Microsoft.Data.Sqlite dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Plugin.BrowserBookmark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index d7a626e1d..df534cb3f 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -95,7 +95,7 @@ - + From 8408a3cc544957d90033c34159f5a7391cbf135f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 07:57:00 +0000 Subject: [PATCH 10/18] Bump System.Data.OleDb from 8.0.1 to 9.0.2 Bumps [System.Data.OleDb](https://github.com/dotnet/runtime) from 8.0.1 to 9.0.2. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v8.0.1...v9.0.2) --- updated-dependencies: - dependency-name: System.Data.OleDb dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Plugin.Explorer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj index 29925aeef..f5691cb73 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj @@ -45,7 +45,7 @@ - + From 869fe5f94ac512603a923b1dc282eadc26553538 Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Mon, 10 Mar 2025 09:41:17 +0800 Subject: [PATCH 11/18] Revert "Bump System.Data.OleDb from 8.0.1 to 9.0.2" --- .../Flow.Launcher.Plugin.Explorer.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj index f5691cb73..549217027 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj @@ -45,7 +45,8 @@ - + + From e870dd27eb2016f7d8101660d4e4d5449f82b995 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Wed, 29 May 2024 23:48:04 +0800 Subject: [PATCH 12/18] Allow log level selection --- Flow.Launcher.Infrastructure/Logger/Log.cs | 22 +++++++++++++++---- .../UserSettings/Settings.cs | 2 ++ Flow.Launcher/App.xaml.cs | 14 ++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Logger/Log.cs b/Flow.Launcher.Infrastructure/Logger/Log.cs index d4bd473ac..cce62a1ac 100644 --- a/Flow.Launcher.Infrastructure/Logger/Log.cs +++ b/Flow.Launcher.Infrastructure/Logger/Log.cs @@ -48,17 +48,31 @@ namespace Flow.Launcher.Infrastructure.Logger configuration.AddTarget("file", fileTargetASyncWrapper); configuration.AddTarget("debug", debugTarget); + var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper) + { + RuleName = "file" + }; #if DEBUG - var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper); - var debugRule = new LoggingRule("*", LogLevel.Debug, debugTarget); + var debugRule = new LoggingRule("*", LogLevel.Debug, debugTarget) + { + RuleName = "debug" + }; configuration.LoggingRules.Add(debugRule); -#else - var fileRule = new LoggingRule("*", LogLevel.Info, fileTargetASyncWrapper); #endif configuration.LoggingRules.Add(fileRule); LogManager.Configuration = configuration; } + public static void UseDebugLogLevel() + { + LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal); + } + + public static void UseInfoLogLevel() + { + LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal); + } + private static void LogFaultyFormat(string message) { var logger = LogManager.GetLogger("FaultyLogger"); diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0fb6e2b3c..25beb8bf6 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -199,6 +199,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings } }; + public string LogLevel = "info"; + ///

/// when false Alphabet static service will always return empty results /// diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 447eca792..6ec0424b8 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -122,6 +122,20 @@ namespace Flow.Launcher var imageLoadertask = ImageLoader.InitializeAsync(); + switch (_settings.LogLevel) + { + case "debug": + Log.UseDebugLogLevel(); + break; + case "info": + Log.UseInfoLogLevel(); + break; + default: + Log.Error(nameof(Flow.Launcher.App), "Unrecognized log level"); + Log.UseDebugLogLevel(); + break; + } + AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings); // TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future From 44a90e53a918d3b580edb686b040d0c7cced8233 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 11 Mar 2025 23:53:33 +0800 Subject: [PATCH 13/18] Write log level in log --- Flow.Launcher.Infrastructure/Logger/Log.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Flow.Launcher.Infrastructure/Logger/Log.cs b/Flow.Launcher.Infrastructure/Logger/Log.cs index cce62a1ac..3eb53e0a3 100644 --- a/Flow.Launcher.Infrastructure/Logger/Log.cs +++ b/Flow.Launcher.Infrastructure/Logger/Log.cs @@ -66,11 +66,13 @@ namespace Flow.Launcher.Infrastructure.Logger public static void UseDebugLogLevel() { LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal); + Info(nameof(Logger), "Using DEBUG log level."); } public static void UseInfoLogLevel() { LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal); + Info(nameof(Logger), "Using INFO log level."); } private static void LogFaultyFormat(string message) From 1dfa15d325e9f43336dcbd6eac1ee934e15f9de7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:13:52 +0000 Subject: [PATCH 14/18] Bump Microsoft.Data.Sqlite from 9.0.2 to 9.0.3 Bumps [Microsoft.Data.Sqlite](https://github.com/dotnet/efcore) from 9.0.2 to 9.0.3. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v9.0.2...v9.0.3) --- updated-dependencies: - dependency-name: Microsoft.Data.Sqlite dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Plugin.BrowserBookmark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index df534cb3f..b4e42fbcd 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -95,7 +95,7 @@ - + From 8d3fd756dd2ef5ed79113e9d4d4568b45820dbdf Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Wed, 12 Mar 2025 08:57:03 +0800 Subject: [PATCH 15/18] Add getter and setter --- Flow.Launcher.Infrastructure/UserSettings/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 25beb8bf6..0a9d99777 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -199,7 +199,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings } }; - public string LogLevel = "info"; + public string LogLevel { get; set; } = "info"; /// /// when false Alphabet static service will always return empty results From 11acca6215a9234c0ee055d6fef816d1bde933f8 Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Wed, 12 Mar 2025 12:01:39 +0800 Subject: [PATCH 16/18] Move log level to enum & Use info level as default --- Flow.Launcher.Infrastructure/Logger/Log.cs | 10 ++++++++-- Flow.Launcher.Infrastructure/UserSettings/Settings.cs | 4 +++- Flow.Launcher/App.xaml.cs | 8 ++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Logger/Log.cs b/Flow.Launcher.Infrastructure/Logger/Log.cs index 3eb53e0a3..2f368ac0c 100644 --- a/Flow.Launcher.Infrastructure/Logger/Log.cs +++ b/Flow.Launcher.Infrastructure/Logger/Log.cs @@ -66,13 +66,13 @@ namespace Flow.Launcher.Infrastructure.Logger public static void UseDebugLogLevel() { LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal); - Info(nameof(Logger), "Using DEBUG log level."); + Info(nameof(Logger), "Using log level: DEBUG."); } public static void UseInfoLogLevel() { LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal); - Info(nameof(Logger), "Using INFO log level."); + Info(nameof(Logger), "Using log level: INFO."); } private static void LogFaultyFormat(string message) @@ -222,4 +222,10 @@ namespace Flow.Launcher.Infrastructure.Logger LogInternal(message, LogLevel.Warn); } } + + public enum LOGLEVEL + { + DEBUG, + INFO + } } diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0a9d99777..93f6db111 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -5,6 +5,7 @@ using System.Text.Json.Serialization; using System.Windows; using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; @@ -199,7 +200,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings } }; - public string LogLevel { get; set; } = "info"; + [JsonConverter(typeof(JsonStringEnumConverter))] + public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.INFO; /// /// when false Alphabet static service will always return empty results diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 6ec0424b8..ec4bb8dc6 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -124,15 +124,11 @@ namespace Flow.Launcher switch (_settings.LogLevel) { - case "debug": + case LOGLEVEL.DEBUG: Log.UseDebugLogLevel(); break; - case "info": - Log.UseInfoLogLevel(); - break; default: - Log.Error(nameof(Flow.Launcher.App), "Unrecognized log level"); - Log.UseDebugLogLevel(); + Log.UseInfoLogLevel(); break; } From 05ff797613c952aedde47a1cfc55efe924ab6682 Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Wed, 12 Mar 2025 12:26:29 +0800 Subject: [PATCH 17/18] Use one function to set log level --- Flow.Launcher.Infrastructure/Logger/Log.cs | 22 +++++++++++++++++----- Flow.Launcher/App.xaml.cs | 12 ++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Logger/Log.cs b/Flow.Launcher.Infrastructure/Logger/Log.cs index 2f368ac0c..7f847e287 100644 --- a/Flow.Launcher.Infrastructure/Logger/Log.cs +++ b/Flow.Launcher.Infrastructure/Logger/Log.cs @@ -63,16 +63,28 @@ namespace Flow.Launcher.Infrastructure.Logger LogManager.Configuration = configuration; } - public static void UseDebugLogLevel() + public static void SetLogLevel(LOGLEVEL level) { - LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal); - Info(nameof(Logger), "Using log level: DEBUG."); + switch (level) + { + case LOGLEVEL.DEBUG: + UseDebugLogLevel(); + break; + default: + UseInfoLogLevel(); + break; + } + Info(nameof(Logger), $"Using log level: {level}."); } - public static void UseInfoLogLevel() + private static void UseDebugLogLevel() + { + LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal); + } + + private static void UseInfoLogLevel() { LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal); - Info(nameof(Logger), "Using log level: INFO."); } private static void LogFaultyFormat(string message) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index ec4bb8dc6..ab68cf426 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -112,6 +112,8 @@ namespace Flow.Launcher { await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () => { + Log.SetLogLevel(_settings.LogLevel); + Ioc.Default.GetRequiredService().PreStartCleanUpAfterPortabilityUpdate(); Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------"); @@ -122,16 +124,6 @@ namespace Flow.Launcher var imageLoadertask = ImageLoader.InitializeAsync(); - switch (_settings.LogLevel) - { - case LOGLEVEL.DEBUG: - Log.UseDebugLogLevel(); - break; - default: - Log.UseInfoLogLevel(); - break; - } - AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings); // TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future From 66bf04642a6d9857dd2c91e23a0c5385b4ccddcc Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Wed, 12 Mar 2025 12:33:26 +0800 Subject: [PATCH 18/18] Add log level change to general settings page --- Flow.Launcher/Languages/en.xaml | 3 +++ .../SettingsPaneGeneralViewModel.cs | 22 +++++++++++++++++++ .../Views/SettingsPaneGeneral.xaml | 8 +++++++ 3 files changed, 33 insertions(+) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 058a51ae3..2ead21cf5 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -104,6 +104,9 @@ Always Preview Always open preview panel when Flow activates. Press {0} to toggle preview. Shadow effect is not allowed while current theme has blur effect enabled + Log level + Debug + Info Search Plugin diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index dddaa99d4..e4f88432a 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -7,6 +7,7 @@ using Flow.Launcher.Core; using Flow.Launcher.Core.Configuration; using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; @@ -31,6 +32,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel public class SearchWindowAlignData : DropdownDataGeneric { } public class SearchPrecisionData : DropdownDataGeneric { } public class LastQueryModeData : DropdownDataGeneric { } + public class LogLevelData : DropdownDataGeneric { } public bool StartFlowLauncherOnSystemStartup { @@ -143,12 +145,16 @@ public partial class SettingsPaneGeneralViewModel : BaseModel public List LastQueryModes { get; } = DropdownDataGeneric.GetValues("LastQuery"); + public List LogLevels { get; } = + DropdownDataGeneric.GetValues("LogLevel"); + private void UpdateEnumDropdownLocalizations() { DropdownDataGeneric.UpdateLabels(SearchWindowScreens); DropdownDataGeneric.UpdateLabels(SearchWindowAligns); DropdownDataGeneric.UpdateLabels(SearchPrecisionScores); DropdownDataGeneric.UpdateLabels(LastQueryModes); + DropdownDataGeneric.UpdateLabels(LogLevels); } public string Language @@ -216,6 +222,22 @@ public partial class SettingsPaneGeneralViewModel : BaseModel } } + public LOGLEVEL LogLevel + { + get => Settings.LogLevel; + set + { + if (Settings.LogLevel != value) + { + Settings.LogLevel = value; + + Log.SetLogLevel(value); + + UpdateEnumDropdownLocalizations(); + } + } + } + [RelayCommand] private void SelectPython() { diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml index a80e618e8..814eda16b 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml @@ -278,6 +278,14 @@ SelectedValue="{Binding Language}" SelectedValuePath="LanguageCode" /> + + + +