Skip to content

Commit 05ff797

Browse files
committed
Use one function to set log level
1 parent 11acca6 commit 05ff797

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,28 @@ static Log()
6363
LogManager.Configuration = configuration;
6464
}
6565

66-
public static void UseDebugLogLevel()
66+
public static void SetLogLevel(LOGLEVEL level)
67+
{
68+
switch (level)
69+
{
70+
case LOGLEVEL.DEBUG:
71+
UseDebugLogLevel();
72+
break;
73+
default:
74+
UseInfoLogLevel();
75+
break;
76+
}
77+
Info(nameof(Logger), $"Using log level: {level}.");
78+
}
79+
80+
private static void UseDebugLogLevel()
6781
{
6882
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
69-
Info(nameof(Logger), "Using log level: DEBUG.");
7083
}
7184

72-
public static void UseInfoLogLevel()
85+
private static void UseInfoLogLevel()
7386
{
7487
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
75-
Info(nameof(Logger), "Using log level: INFO.");
7688
}
7789

7890
private static void LogFaultyFormat(string message)

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
112112
{
113113
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
114114
{
115+
Log.SetLogLevel(_settings.LogLevel);
116+
115117
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
116118

117119
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");
@@ -122,16 +124,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
122124

123125
var imageLoadertask = ImageLoader.InitializeAsync();
124126

125-
switch (_settings.LogLevel)
126-
{
127-
case LOGLEVEL.DEBUG:
128-
Log.UseDebugLogLevel();
129-
break;
130-
default:
131-
Log.UseInfoLogLevel();
132-
break;
133-
}
134-
135127
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
136128

137129
// TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future

0 commit comments

Comments
 (0)