Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions Flow.Launcher.Infrastructure/Logger/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using Flow.Launcher.Infrastructure.UserSettings;
using NLog;

Check warning on line 6 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`NLog` is not a recognized word. (unrecognized-spelling)
using NLog.Config;

Check warning on line 7 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`NLog` is not a recognized word. (unrecognized-spelling)
using NLog.Targets;

Check warning on line 8 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`NLog` is not a recognized word. (unrecognized-spelling)
using NLog.Targets.Wrappers;

Check warning on line 9 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`NLog` is not a recognized word. (unrecognized-spelling)

namespace Flow.Launcher.Infrastructure.Logger
{
Expand All @@ -16,7 +16,7 @@

public static string CurrentLogDirectory { get; }

static Log()
static Log()
{
CurrentLogDirectory = DataLocation.VersionLogDirectory;
if (!Directory.Exists(CurrentLogDirectory))
Expand All @@ -27,14 +27,14 @@
var configuration = new LoggingConfiguration();

const string layout =
@"${date:format=HH\:mm\:ss.ffffK} - " +

Check warning on line 30 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`ffff` is not a recognized word. (unrecognized-spelling)
@"${level:uppercase=true:padding=-5} - ${logger} - ${message:l}" +
@"${onexception:${newline}" +

Check warning on line 32 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`onexception` is not a recognized word. (unrecognized-spelling)
@"EXCEPTION OCCURS\: ${exception:format=tostring}${newline}}";

var fileTarget = new FileTarget
{
FileName = CurrentLogDirectory.Replace(@"\", "/") + "/${shortdate}.txt",
FileName = CurrentLogDirectory.Replace(@"\", "/") + "/Flow.Launcher.${date:format=yyyyMMdd}.log",

Check warning on line 37 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`MMdd` is not a recognized word. (unrecognized-spelling)
Layout = layout
};

Expand All @@ -45,6 +45,8 @@
Layout = layout
};



configuration.AddTarget("file", fileTargetASyncWrapper);
configuration.AddTarget("debug", debugTarget);

Expand All @@ -65,26 +67,22 @@

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);

Check warning on line 80 in Flow.Launcher.Infrastructure/Logger/Log.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`nlog` is not a recognized word. (unrecognized-spelling)

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)
Expand Down Expand Up @@ -169,7 +167,9 @@

public enum LOGLEVEL
{
DEBUG,
INFO
None,
Error,
Info,
Debug
}
}
2 changes: 1 addition & 1 deletion Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public CustomBrowserViewModel CustomBrowser
public DialogJumpFileResultBehaviours DialogJumpFileResultBehaviour { get; set; } = DialogJumpFileResultBehaviours.FullPath;

[JsonConverter(typeof(JsonStringEnumConverter))]
public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.INFO;
public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.Info;

/// <summary>
/// when false Alphabet static service will always return empty results
Expand Down
8 changes: 5 additions & 3 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,13 @@
<system:String x:Key="welcomewindow">Wizard</system:String>
<system:String x:Key="userdatapath">User Data Location</system:String>
<system:String x:Key="userdatapathToolTip">User settings and installed plugins are saved in the user data folder. This location may vary depending on whether it's in portable mode or not.</system:String>
<system:String x:Key="userdatapathButton">Open Folder</system:String>
<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="LogLevelINFO">Info</system:String>
<system:String x:Key="LogLevelNone">None</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 -->
Expand Down
Loading