Resolve CodeFactor issue.
MODIFY
WalletWasabi.Backend/Program.cs
WalletWasabi.Backend/Program.cs
@@ -19,14 +19,7 @@ namespace WalletWasabi.Backend
{
try
{
- Logger.SetFilePath(Path.Combine(Global.DataDir, "Logs.txt"));
-#if RELEASE
- Logger.SetMinimumLevel(LogLevel.Info);
- Logger.SetModes(LogMode.File);
-#else
- Logger.SetMinimumLevel(LogLevel.Debug);
- Logger.SetModes(LogMode.Debug, LogMode.Console, LogMode.File);
-#endif
+ Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt"));
var configFilePath = Path.Combine(Global.DataDir, "Config.json");
var config = new Config(configFilePath);

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -26,14 +26,8 @@ namespace WalletWasabi.Gui
{
try
{
- Logger.SetFilePath(Path.Combine(Global.DataDir, "Logs.txt"));
-#if RELEASE
- Logger.SetMinimumLevel(LogLevel.Info);
- Logger.SetModes(LogMode.File);
-#else
- Logger.SetMinimumLevel(LogLevel.Debug);
- Logger.SetModes(LogMode.Debug, LogMode.Console, LogMode.File);
-#endif
+ Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt"));
+
var configFilePath = Path.Combine(Global.DataDir, "Config.json");
var config = new Config(configFilePath);
await config.LoadOrCreateDefaultFileAsync();

MODIFY
WalletWasabi/Logging/Logger.cs
WalletWasabi/Logging/Logger.cs
@@ -37,6 +37,25 @@ namespace WalletWasabi.Logging
#region Initializers
+ /// <summary>
+ /// Initializes the Logger with default values.
+ /// If RELEASE then minlevel is info, and logs only to file.
+ /// If DEBUG then minlevel is debug, and logs to file, debug and console.
+ /// </summary>
+ /// <param name="filePath"></param>
+ public static void InitializeDefaults(string filePath)
+ {
+ SetFilePath(filePath);
+
+#if RELEASE
+ SetMinimumLevel(LogLevel.Info);
+ SetModes(LogMode.File);
+#else
+ SetMinimumLevel(LogLevel.Debug);
+ SetModes(LogMode.Debug, LogMode.Console, LogMode.File);
+#endif
+ }
+
public static void SetMinimumLevel(LogLevel level) => MinimumLevel = level;
public static void SetModes(params LogMode[] modes)

Resolve CodeFactor issue.