mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2739 from Flow-Launcher/debug-log-level
Allow log level selection
This commit is contained in:
commit
9b2148f7c2
6 changed files with 77 additions and 4 deletions
|
|
@ -48,17 +48,45 @@ namespace Flow.Launcher.Infrastructure.Logger
|
||||||
configuration.AddTarget("file", fileTargetASyncWrapper);
|
configuration.AddTarget("file", fileTargetASyncWrapper);
|
||||||
configuration.AddTarget("debug", debugTarget);
|
configuration.AddTarget("debug", debugTarget);
|
||||||
|
|
||||||
|
var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper)
|
||||||
|
{
|
||||||
|
RuleName = "file"
|
||||||
|
};
|
||||||
#if DEBUG
|
#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);
|
configuration.LoggingRules.Add(debugRule);
|
||||||
#else
|
|
||||||
var fileRule = new LoggingRule("*", LogLevel.Info, fileTargetASyncWrapper);
|
|
||||||
#endif
|
#endif
|
||||||
configuration.LoggingRules.Add(fileRule);
|
configuration.LoggingRules.Add(fileRule);
|
||||||
LogManager.Configuration = configuration;
|
LogManager.Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetLogLevel(LOGLEVEL level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case LOGLEVEL.DEBUG:
|
||||||
|
UseDebugLogLevel();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UseInfoLogLevel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Info(nameof(Logger), $"Using log level: {level}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
private static void LogFaultyFormat(string message)
|
private static void LogFaultyFormat(string message)
|
||||||
{
|
{
|
||||||
var logger = LogManager.GetLogger("FaultyLogger");
|
var logger = LogManager.GetLogger("FaultyLogger");
|
||||||
|
|
@ -206,4 +234,10 @@ namespace Flow.Launcher.Infrastructure.Logger
|
||||||
LogInternal(message, LogLevel.Warn);
|
LogInternal(message, LogLevel.Warn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum LOGLEVEL
|
||||||
|
{
|
||||||
|
DEBUG,
|
||||||
|
INFO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Text.Json.Serialization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||||
using Flow.Launcher.Infrastructure.Hotkey;
|
using Flow.Launcher.Infrastructure.Hotkey;
|
||||||
|
using Flow.Launcher.Infrastructure.Logger;
|
||||||
using Flow.Launcher.Infrastructure.Storage;
|
using Flow.Launcher.Infrastructure.Storage;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
using Flow.Launcher.Plugin.SharedModels;
|
using Flow.Launcher.Plugin.SharedModels;
|
||||||
|
|
@ -199,6 +200,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
|
public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.INFO;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// when false Alphabet static service will always return empty results
|
/// when false Alphabet static service will always return empty results
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,8 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
|
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
|
||||||
{
|
{
|
||||||
|
Log.SetLogLevel(_settings.LogLevel);
|
||||||
|
|
||||||
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
|
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
|
||||||
|
|
||||||
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");
|
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,9 @@
|
||||||
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
|
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
|
||||||
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
|
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
|
||||||
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
|
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
|
||||||
|
<system:String x:Key="logLevel">Log level</system:String>
|
||||||
|
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
|
||||||
|
<system:String x:Key="LogLevelINFO">Info</system:String>
|
||||||
|
|
||||||
<!-- Setting Plugin -->
|
<!-- Setting Plugin -->
|
||||||
<system:String x:Key="searchplugin">Search Plugin</system:String>
|
<system:String x:Key="searchplugin">Search Plugin</system:String>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Flow.Launcher.Core;
|
||||||
using Flow.Launcher.Core.Configuration;
|
using Flow.Launcher.Core.Configuration;
|
||||||
using Flow.Launcher.Core.Resource;
|
using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.Helper;
|
using Flow.Launcher.Helper;
|
||||||
|
using Flow.Launcher.Infrastructure.Logger;
|
||||||
using Flow.Launcher.Infrastructure.UserSettings;
|
using Flow.Launcher.Infrastructure.UserSettings;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
using Flow.Launcher.Plugin.SharedModels;
|
using Flow.Launcher.Plugin.SharedModels;
|
||||||
|
|
@ -31,6 +32,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
||||||
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
|
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
|
||||||
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
|
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
|
||||||
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
|
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
|
||||||
|
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
|
||||||
|
|
||||||
public bool StartFlowLauncherOnSystemStartup
|
public bool StartFlowLauncherOnSystemStartup
|
||||||
{
|
{
|
||||||
|
|
@ -143,12 +145,16 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
||||||
public List<LastQueryModeData> LastQueryModes { get; } =
|
public List<LastQueryModeData> LastQueryModes { get; } =
|
||||||
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
|
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
|
||||||
|
|
||||||
|
public List<LogLevelData> LogLevels { get; } =
|
||||||
|
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
|
||||||
|
|
||||||
private void UpdateEnumDropdownLocalizations()
|
private void UpdateEnumDropdownLocalizations()
|
||||||
{
|
{
|
||||||
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
|
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
|
||||||
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
|
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
|
||||||
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
|
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
|
||||||
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
|
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
|
||||||
|
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Language
|
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]
|
[RelayCommand]
|
||||||
private void SelectPython()
|
private void SelectPython()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,14 @@
|
||||||
SelectedValue="{Binding Language}"
|
SelectedValue="{Binding Language}"
|
||||||
SelectedValuePath="LanguageCode" />
|
SelectedValuePath="LanguageCode" />
|
||||||
</cc:Card>
|
</cc:Card>
|
||||||
|
|
||||||
|
<cc:Card Title="{DynamicResource logLevel}" Margin="0 14 0 0">
|
||||||
|
<ComboBox
|
||||||
|
DisplayMemberPath="Display"
|
||||||
|
ItemsSource="{Binding LogLevels}"
|
||||||
|
SelectedValue="{Binding LogLevel}"
|
||||||
|
SelectedValuePath="Value" />
|
||||||
|
</cc:Card>
|
||||||
</VirtualizingStackPanel>
|
</VirtualizingStackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</ui:Page>
|
</ui:Page>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue