mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Allow log level selection
This commit is contained in:
parent
36e10a175c
commit
e870dd27eb
3 changed files with 34 additions and 4 deletions
|
|
@ -48,17 +48,31 @@ 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 UseDebugLogLevel()
|
||||||
|
{
|
||||||
|
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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");
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public string 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>
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,20 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
var imageLoadertask = ImageLoader.InitializeAsync();
|
var imageLoadertask = ImageLoader.InitializeAsync();
|
||||||
|
|
||||||
|
switch (_settings.LogLevel)
|
||||||
|
{
|
||||||
|
case "debug":
|
||||||
|
Log.UseDebugLogLevel();
|
||||||
|
break;
|
||||||
|
case "info":
|
||||||
|
Log.UseInfoLogLevel();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.Error(nameof(Flow.Launcher.App), "Unrecognized log level");
|
||||||
|
Log.UseDebugLogLevel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
|
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
|
||||||
|
|
||||||
// TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future
|
// TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue