Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 18 additions & 20 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 @@ -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=yyyy-MM-dd}.log",
Layout = layout
};

Expand Down Expand Up @@ -65,26 +65,22 @@

public static void SetLogLevel(LOGLEVEL level)
{
switch (level)
var rule = LogManager.Configuration.FindRuleByName("file");

var nlogLevel = level switch

Check warning on line 70 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)
{
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 78 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 +165,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
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text.Json.Serialization;
using System.Windows;
Expand Down
4 changes: 3 additions & 1 deletion Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
Loading