mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3976 from dcog989/logging-enhanced
Enhanced logging
This commit is contained in:
commit
51df66e362
3 changed files with 22 additions and 22 deletions
|
|
@ -34,7 +34,7 @@ namespace Flow.Launcher.Infrastructure.Logger
|
|||
|
||||
var fileTarget = new FileTarget
|
||||
{
|
||||
FileName = CurrentLogDirectory.Replace(@"\", "/") + "/${shortdate}.txt",
|
||||
FileName = CurrentLogDirectory.Replace(@"\", "/") + "/Flow.Launcher.${date:format=yyyy-MM-dd}.log",
|
||||
Layout = layout
|
||||
};
|
||||
|
||||
|
|
@ -65,26 +65,22 @@ namespace Flow.Launcher.Infrastructure.Logger
|
|||
|
||||
public static void SetLogLevel(LOGLEVEL level)
|
||||
{
|
||||
switch (level)
|
||||
var rule = LogManager.Configuration.FindRuleByName("file");
|
||||
|
||||
var nlogLevel = level switch
|
||||
{
|
||||
case LOGLEVEL.DEBUG:
|
||||
UseDebugLogLevel();
|
||||
break;
|
||||
default:
|
||||
UseInfoLogLevel();
|
||||
break;
|
||||
}
|
||||
Info(nameof(Logger), $"Using log level: {level}.");
|
||||
}
|
||||
LOGLEVEL.NONE => LogLevel.Off,
|
||||
LOGLEVEL.ERROR => LogLevel.Error,
|
||||
LOGLEVEL.DEBUG => LogLevel.Debug,
|
||||
_ => LogLevel.Info
|
||||
};
|
||||
|
||||
private static void UseDebugLogLevel()
|
||||
{
|
||||
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
|
||||
}
|
||||
rule.SetLoggingLevels(nlogLevel, LogLevel.Fatal);
|
||||
|
||||
private static void UseInfoLogLevel()
|
||||
{
|
||||
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
|
||||
// We can't log Info when level is set to Error or None, so we use Debug
|
||||
Debug(nameof(Logger), $"Using log level: {level}.");
|
||||
}
|
||||
|
||||
private static void LogFaultyFormat(string message)
|
||||
|
|
@ -169,7 +165,9 @@ namespace Flow.Launcher.Infrastructure.Logger
|
|||
|
||||
public enum LOGLEVEL
|
||||
{
|
||||
DEBUG,
|
||||
INFO
|
||||
NONE,
|
||||
ERROR,
|
||||
INFO,
|
||||
DEBUG
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Windows;
|
||||
|
|
|
|||
|
|
@ -462,8 +462,10 @@
|
|||
<system:String x:Key="userdatapathButton">Open Folder</system:String>
|
||||
<system:String x:Key="advanced">Advanced</system:String>
|
||||
<system:String x:Key="logLevel">Log Level</system:String>
|
||||
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
|
||||
<system:String x:Key="LogLevelNONE">Silent</system:String>
|
||||
<system:String x:Key="LogLevelERROR">Error</system:String>
|
||||
<system:String x:Key="LogLevelINFO">Info</system:String>
|
||||
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
|
||||
<system:String x:Key="settingWindowFontTitle">Setting Window Font</system:String>
|
||||
|
||||
<!-- Release Notes Window -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue