mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Initialize console loggers only once
This commit is contained in:
@@ -42,6 +42,7 @@ namespace ArchiSteamFarm {
|
||||
internal static void Init() {
|
||||
if (LogManager.Configuration != null) {
|
||||
// User provided custom NLog config, or we have it set already, so don't override it
|
||||
InitConsoleLoggers();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,14 +76,10 @@ namespace ArchiSteamFarm {
|
||||
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
|
||||
|
||||
LogManager.Configuration = config;
|
||||
InitConsoleLoggers();
|
||||
}
|
||||
|
||||
internal static void OnUserInputStart() {
|
||||
ConsoleLoggingRules.Clear();
|
||||
foreach (LoggingRule loggingRule in from loggingRule in LogManager.Configuration.LoggingRules from target in loggingRule.Targets where target is ColoredConsoleTarget || target is ConsoleTarget select loggingRule) {
|
||||
ConsoleLoggingRules.Add(loggingRule);
|
||||
}
|
||||
|
||||
if (ConsoleLoggingRules.Count == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -170,5 +167,11 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Logger.Debug($"{botName}|{previousMethodName}() {message}");
|
||||
}
|
||||
|
||||
private static void InitConsoleLoggers() {
|
||||
foreach (LoggingRule loggingRule in from loggingRule in LogManager.Configuration.LoggingRules from target in loggingRule.Targets where target is ColoredConsoleTarget || target is ConsoleTarget select loggingRule) {
|
||||
ConsoleLoggingRules.Add(loggingRule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user