Skip to content

Commit 11acca6

Browse files
committed
Move log level to enum & Use info level as default
1 parent 3fe52f9 commit 11acca6

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ static Log()
6666
public static void UseDebugLogLevel()
6767
{
6868
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
69-
Info(nameof(Logger), "Using DEBUG log level.");
69+
Info(nameof(Logger), "Using log level: DEBUG.");
7070
}
7171

7272
public static void UseInfoLogLevel()
7373
{
7474
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
75-
Info(nameof(Logger), "Using INFO log level.");
75+
Info(nameof(Logger), "Using log level: INFO.");
7676
}
7777

7878
private static void LogFaultyFormat(string message)
@@ -222,4 +222,10 @@ public static void Warn(string message)
222222
LogInternal(message, LogLevel.Warn);
223223
}
224224
}
225+
226+
public enum LOGLEVEL
227+
{
228+
DEBUG,
229+
INFO
230+
}
225231
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows;
66
using CommunityToolkit.Mvvm.DependencyInjection;
77
using Flow.Launcher.Infrastructure.Hotkey;
8+
using Flow.Launcher.Infrastructure.Logger;
89
using Flow.Launcher.Infrastructure.Storage;
910
using Flow.Launcher.Plugin;
1011
using Flow.Launcher.Plugin.SharedModels;
@@ -199,7 +200,8 @@ public CustomBrowserViewModel CustomBrowser
199200
}
200201
};
201202

202-
public string LogLevel { get; set; } = "info";
203+
[JsonConverter(typeof(JsonStringEnumConverter))]
204+
public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.INFO;
203205

204206
/// <summary>
205207
/// when false Alphabet static service will always return empty results

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,11 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
124124

125125
switch (_settings.LogLevel)
126126
{
127-
case "debug":
127+
case LOGLEVEL.DEBUG:
128128
Log.UseDebugLogLevel();
129129
break;
130-
case "info":
131-
Log.UseInfoLogLevel();
132-
break;
133130
default:
134-
Log.Error(nameof(Flow.Launcher.App), "Unrecognized log level");
135-
Log.UseDebugLogLevel();
131+
Log.UseInfoLogLevel();
136132
break;
137133
}
138134

0 commit comments

Comments
 (0)