mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Gigantic code cleanup
Time to enforce some common file layout, as general mess started to annoying me. Sorry in advance for people using custom forks and having merge conflicts, this will help everybody in long-run
This commit is contained in:
@@ -29,6 +29,7 @@ using NLog.Targets;
|
||||
using NLog.Windows.Forms;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Logging {
|
||||
private const string GeneralLayout = @"${date:format=yyyy-MM-dd HH\:mm\:ss} | ${level:uppercase=true} | ${logger} | ${message}${onexception:inner= | ${exception:format=toString,Data}}";
|
||||
@@ -46,10 +47,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
MessageBoxTarget messageBoxTarget = new MessageBoxTarget {
|
||||
Name = "MessageBox",
|
||||
Layout = GeneralLayout
|
||||
};
|
||||
MessageBoxTarget messageBoxTarget = new MessageBoxTarget { Name = "MessageBox", Layout = GeneralLayout };
|
||||
|
||||
LogManager.Configuration.AddTarget(messageBoxTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Fatal, messageBoxTarget));
|
||||
@@ -61,11 +59,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
FileTarget fileTarget = new FileTarget("File") {
|
||||
DeleteOldFileOnStartup = true,
|
||||
FileName = SharedInfo.LogFile,
|
||||
Layout = GeneralLayout
|
||||
};
|
||||
FileTarget fileTarget = new FileTarget("File") { DeleteOldFileOnStartup = true, FileName = SharedInfo.LogFile, Layout = GeneralLayout };
|
||||
|
||||
LogManager.Configuration.AddTarget(fileTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));
|
||||
@@ -74,23 +68,15 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal static void InitFormLogger() {
|
||||
RichTextBoxTarget formControlTarget = new RichTextBoxTarget {
|
||||
AutoScroll = true,
|
||||
ControlName = "LogTextBox",
|
||||
FormName = "MainForm",
|
||||
Layout = GeneralLayout,
|
||||
MaxLines = byte.MaxValue,
|
||||
Name = "RichTextBox"
|
||||
};
|
||||
RichTextBoxTarget formControlTarget = new RichTextBoxTarget { AutoScroll = true, ControlName = "LogTextBox", FormName = "MainForm", Layout = GeneralLayout, MaxLines = byte.MaxValue, Name = "RichTextBox" };
|
||||
|
||||
formControlTarget.RowColoringRules.Add(new RichTextBoxRowColoringRule("level >= LogLevel.Error", "Red", "Black"));
|
||||
formControlTarget.RowColoringRules.Add(new RichTextBoxRowColoringRule("level >= LogLevel.Warn", "Yellow", "Black"));
|
||||
|
||||
|
||||
LogManager.Configuration.AddTarget(formControlTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, formControlTarget));
|
||||
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user