Move log level to enum & Use info level as default

This commit is contained in:
Jack Ye 2025-03-12 12:01:39 +08:00
parent 3fe52f91a9
commit 11acca6215
3 changed files with 13 additions and 9 deletions

View file

@ -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
}
}

View file

@ -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;
/// <summary>
/// when false Alphabet static service will always return empty results

View file

@ -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;
}