2019-02-16 17:34:17 +01:00
|
|
|
|
// _ _ _ ____ _ _____
|
2017-11-18 17:27:06 +01:00
|
|
|
|
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
|
|
|
|
|
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
|
|
|
|
|
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
|
|
|
|
|
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
2019-01-14 19:11:17 +01:00
|
|
|
|
// |
|
2019-01-02 16:32:53 +01:00
|
|
|
|
// Copyright 2015-2019 Łukasz "JustArchi" Domeradzki
|
2018-07-27 04:52:14 +02:00
|
|
|
|
// Contact: JustArchi@JustArchi.net
|
2019-01-14 19:11:17 +01:00
|
|
|
|
// |
|
2018-07-27 04:52:14 +02:00
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
|
// You may obtain a copy of the License at
|
2019-01-14 19:11:17 +01:00
|
|
|
|
// |
|
2018-07-27 04:52:14 +02:00
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2019-01-14 19:11:17 +01:00
|
|
|
|
// |
|
2018-07-27 04:52:14 +02:00
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
|
// limitations under the License.
|
2015-10-28 19:21:27 +01:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
using System;
|
2016-07-04 21:58:50 +02:00
|
|
|
|
using System.Linq;
|
2019-02-23 04:31:58 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2018-09-08 01:03:55 +02:00
|
|
|
|
using ArchiSteamFarm.Collections;
|
2018-09-08 00:05:23 +02:00
|
|
|
|
using ArchiSteamFarm.IPC;
|
2019-02-23 04:31:58 +01:00
|
|
|
|
using ArchiSteamFarm.Localization;
|
|
|
|
|
|
using JetBrains.Annotations;
|
2016-07-04 19:22:46 +02:00
|
|
|
|
using NLog;
|
|
|
|
|
|
using NLog.Config;
|
|
|
|
|
|
using NLog.Targets;
|
2015-10-25 06:16:50 +01:00
|
|
|
|
|
2018-09-08 01:03:55 +02:00
|
|
|
|
namespace ArchiSteamFarm.NLog {
|
2016-06-10 00:49:44 +02:00
|
|
|
|
internal static class Logging {
|
2019-02-23 04:31:58 +01:00
|
|
|
|
private const byte ConsoleResponsivenessDelay = 250; // In miliseconds
|
2016-11-24 07:32:16 +01:00
|
|
|
|
private const string GeneralLayout = @"${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|" + LayoutMessage;
|
|
|
|
|
|
private const string LayoutMessage = @"${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}";
|
2016-06-10 00:49:44 +02:00
|
|
|
|
|
2016-07-07 23:27:34 +02:00
|
|
|
|
private static readonly ConcurrentHashSet<LoggingRule> ConsoleLoggingRules = new ConcurrentHashSet<LoggingRule>();
|
2019-02-23 04:31:58 +01:00
|
|
|
|
private static readonly SemaphoreSlim ConsoleSemaphore = new SemaphoreSlim(1, 1);
|
2016-06-10 00:49:44 +02:00
|
|
|
|
|
2017-06-26 01:37:14 +02:00
|
|
|
|
private static bool IsUsingCustomConfiguration;
|
2016-08-06 22:16:46 +02:00
|
|
|
|
private static bool IsWaitingForUserInput;
|
2016-07-04 22:30:29 +02:00
|
|
|
|
|
2017-06-26 01:39:22 +02:00
|
|
|
|
internal static void EnableTraceLogging() {
|
2017-06-26 01:37:14 +02:00
|
|
|
|
if (IsUsingCustomConfiguration || (LogManager.Configuration == null)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool reload = false;
|
2018-12-15 00:27:15 +01:00
|
|
|
|
|
2017-06-26 01:37:14 +02:00
|
|
|
|
foreach (LoggingRule rule in LogManager.Configuration.LoggingRules.Where(rule => rule.IsLoggingEnabledForLevel(LogLevel.Debug) && !rule.IsLoggingEnabledForLevel(LogLevel.Trace))) {
|
|
|
|
|
|
rule.EnableLoggingForLevel(LogLevel.Trace);
|
|
|
|
|
|
reload = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (reload) {
|
|
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
internal static async Task<string> GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF) {
|
|
|
|
|
|
if (userInputType == ASF.EUserInputType.Unknown) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ASF.GlobalConfig.Headless) {
|
|
|
|
|
|
ASF.ArchiLogger.LogGenericWarning(Strings.ErrorUserInputRunningInHeadlessMode);
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await ConsoleSemaphore.WaitAsync().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
string result;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
OnUserInputStart();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
Console.Beep();
|
|
|
|
|
|
|
|
|
|
|
|
switch (userInputType) {
|
|
|
|
|
|
case ASF.EUserInputType.DeviceID:
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(Strings.UserInputDeviceID, botName));
|
|
|
|
|
|
result = ConsoleReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case ASF.EUserInputType.Login:
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamLogin, botName));
|
|
|
|
|
|
result = ConsoleReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case ASF.EUserInputType.Password:
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName));
|
|
|
|
|
|
result = ConsoleReadLineMasked();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case ASF.EUserInputType.SteamGuard:
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName));
|
|
|
|
|
|
result = ConsoleReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case ASF.EUserInputType.SteamParentalCode:
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamParentalCode, botName));
|
|
|
|
|
|
result = ConsoleReadLineMasked();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case ASF.EUserInputType.TwoFactorAuthentication:
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName));
|
|
|
|
|
|
result = ConsoleReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType));
|
|
|
|
|
|
Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName));
|
|
|
|
|
|
result = ConsoleReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!Console.IsOutputRedirected) {
|
|
|
|
|
|
Console.Clear(); // For security purposes
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
OnUserInputEnd();
|
|
|
|
|
|
ASF.ArchiLogger.LogGenericException(e);
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OnUserInputEnd();
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
ConsoleSemaphore.Release();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return !string.IsNullOrEmpty(result) ? result.Trim() : null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-29 23:07:06 +01:00
|
|
|
|
internal static void InitCoreLoggers(bool uniqueInstance) {
|
2016-07-04 21:40:09 +02:00
|
|
|
|
if (LogManager.Configuration != null) {
|
2017-06-26 01:37:14 +02:00
|
|
|
|
IsUsingCustomConfiguration = true;
|
2016-07-04 22:03:12 +02:00
|
|
|
|
InitConsoleLoggers();
|
2016-07-07 23:27:34 +02:00
|
|
|
|
LogManager.ConfigurationChanged += OnConfigurationChanged;
|
2018-12-15 00:27:15 +01:00
|
|
|
|
|
2016-07-04 21:40:09 +02:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-17 09:54:22 +02:00
|
|
|
|
ConfigurationItemFactory.Default.ParseMessageTemplates = false;
|
2016-07-04 19:22:46 +02:00
|
|
|
|
LoggingConfiguration config = new LoggingConfiguration();
|
2016-06-10 00:49:44 +02:00
|
|
|
|
|
2018-05-17 09:54:22 +02:00
|
|
|
|
ColoredConsoleTarget coloredConsoleTarget = new ColoredConsoleTarget("ColoredConsole") { Layout = GeneralLayout };
|
2016-07-04 22:30:29 +02:00
|
|
|
|
|
2016-09-21 19:26:20 +02:00
|
|
|
|
config.AddTarget(coloredConsoleTarget);
|
2016-11-06 12:19:43 +01:00
|
|
|
|
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, coloredConsoleTarget));
|
2016-07-04 22:30:29 +02:00
|
|
|
|
|
2019-03-29 23:07:06 +01:00
|
|
|
|
if (uniqueInstance) {
|
|
|
|
|
|
FileTarget fileTarget = new FileTarget("File") {
|
|
|
|
|
|
CleanupFileName = false,
|
|
|
|
|
|
ConcurrentWrites = false,
|
|
|
|
|
|
DeleteOldFileOnStartup = true,
|
|
|
|
|
|
FileName = SharedInfo.LogFile,
|
|
|
|
|
|
Layout = GeneralLayout
|
|
|
|
|
|
};
|
2017-06-26 08:42:00 +02:00
|
|
|
|
|
2019-03-29 23:07:06 +01:00
|
|
|
|
config.AddTarget(fileTarget);
|
|
|
|
|
|
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));
|
|
|
|
|
|
}
|
2016-07-04 19:22:46 +02:00
|
|
|
|
|
2016-08-06 22:16:46 +02:00
|
|
|
|
LogManager.Configuration = config;
|
|
|
|
|
|
InitConsoleLoggers();
|
2016-06-10 00:49:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-31 02:42:23 +01:00
|
|
|
|
internal static void InitHistoryLogger() {
|
2018-07-24 20:37:14 +02:00
|
|
|
|
if (LogManager.Configuration == null) {
|
2018-01-31 02:42:23 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-24 20:43:00 +02:00
|
|
|
|
HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
|
2018-07-24 20:37:14 +02:00
|
|
|
|
|
2018-07-24 20:43:00 +02:00
|
|
|
|
if ((historyTarget == null) && !IsUsingCustomConfiguration) {
|
2018-07-24 20:37:14 +02:00
|
|
|
|
historyTarget = new HistoryTarget("History") {
|
|
|
|
|
|
Layout = GeneralLayout,
|
|
|
|
|
|
MaxCount = 20
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
LogManager.Configuration.AddTarget(historyTarget);
|
|
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, historyTarget));
|
2018-01-31 02:42:23 +01:00
|
|
|
|
|
2018-07-24 20:37:14 +02:00
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
|
|
}
|
2018-01-31 02:42:23 +01:00
|
|
|
|
|
2018-09-08 00:05:23 +02:00
|
|
|
|
ArchiKestrel.OnNewHistoryTarget(historyTarget);
|
2018-01-31 02:42:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
internal static void StartInteractiveConsole() {
|
|
|
|
|
|
if (ASF.GlobalConfig.SteamOwnerID == 0) {
|
|
|
|
|
|
ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.InteractiveConsoleNotAvailable, nameof(ASF.GlobalConfig.SteamOwnerID)));
|
2016-07-07 23:36:35 +02:00
|
|
|
|
|
2016-07-04 21:58:50 +02:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-23 04:56:14 +01:00
|
|
|
|
Utilities.InBackground(HandleConsoleInteractively, true);
|
2019-02-23 04:31:58 +01:00
|
|
|
|
ASF.ArchiLogger.LogGenericInfo(Strings.InteractiveConsoleEnabled);
|
|
|
|
|
|
}
|
2018-05-17 09:54:22 +02:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
private static string ConsoleReadLine() {
|
|
|
|
|
|
Console.Beep();
|
2016-07-04 21:58:50 +02:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
return Console.ReadLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
private static string ConsoleReadLineMasked(char mask = '*') {
|
|
|
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
Console.Beep();
|
|
|
|
|
|
|
|
|
|
|
|
ConsoleKeyInfo keyInfo;
|
|
|
|
|
|
|
|
|
|
|
|
while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter) {
|
|
|
|
|
|
if (!char.IsControl(keyInfo.KeyChar)) {
|
|
|
|
|
|
result.Append(keyInfo.KeyChar);
|
|
|
|
|
|
Console.Write(mask);
|
|
|
|
|
|
} else if ((keyInfo.Key == ConsoleKey.Backspace) && (result.Length > 0)) {
|
|
|
|
|
|
result.Length--;
|
|
|
|
|
|
|
|
|
|
|
|
if (Console.CursorLeft == 0) {
|
|
|
|
|
|
Console.SetCursorPosition(Console.BufferWidth - 1, Console.CursorTop - 1);
|
|
|
|
|
|
Console.Write(' ');
|
|
|
|
|
|
Console.SetCursorPosition(Console.BufferWidth - 1, Console.CursorTop - 1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// There are two \b characters here
|
|
|
|
|
|
Console.Write(@" ");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-17 09:54:22 +02:00
|
|
|
|
}
|
2019-02-23 04:31:58 +01:00
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
|
|
return result.ToString();
|
2016-07-04 21:58:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
private static async Task HandleConsoleInteractively() {
|
|
|
|
|
|
while (!Program.ShutdownSequenceInitialized) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (IsWaitingForUserInput || !Console.KeyAvailable) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2016-07-07 23:36:35 +02:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
await ConsoleSemaphore.WaitAsync().ConfigureAwait(false);
|
2016-07-04 21:58:50 +02:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
try {
|
|
|
|
|
|
ConsoleKeyInfo keyInfo = Console.ReadKey(true);
|
2018-05-17 09:54:22 +02:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
if (keyInfo.Key != ConsoleKey.C) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2016-07-04 21:58:50 +02:00
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
|
OnUserInputStart();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
Console.Write(@">> " + Strings.EnterCommand);
|
|
|
|
|
|
string command = ConsoleReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(command)) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-23 05:02:22 +01:00
|
|
|
|
if (!string.IsNullOrEmpty(ASF.GlobalConfig.CommandPrefix) && command.StartsWith(ASF.GlobalConfig.CommandPrefix, StringComparison.Ordinal)) {
|
|
|
|
|
|
command = command.Substring(ASF.GlobalConfig.CommandPrefix.Length);
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(command)) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-23 08:40:56 +01:00
|
|
|
|
Bot targetBot = Bot.Bots.OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).FirstOrDefault();
|
2019-02-23 04:31:58 +01:00
|
|
|
|
|
|
|
|
|
|
if (targetBot == null) {
|
|
|
|
|
|
Console.WriteLine(@"<< " + Strings.ErrorNoBotsDefined);
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(@"<> " + Strings.Executing);
|
|
|
|
|
|
|
|
|
|
|
|
string response = await targetBot.Commands.Response(ASF.GlobalConfig.SteamOwnerID, command).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(response)) {
|
|
|
|
|
|
ASF.ArchiLogger.LogNullError(nameof(response));
|
|
|
|
|
|
Console.WriteLine(Strings.ErrorIsEmpty, nameof(response));
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(@"<< " + response);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
OnUserInputEnd();
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
ConsoleSemaphore.Release();
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
await Task.Delay(ConsoleResponsivenessDelay).ConfigureAwait(false);
|
|
|
|
|
|
}
|
2018-05-17 09:54:22 +02:00
|
|
|
|
}
|
2016-07-04 21:58:50 +02:00
|
|
|
|
}
|
2016-07-04 19:22:46 +02:00
|
|
|
|
|
2016-07-04 22:03:12 +02:00
|
|
|
|
private static void InitConsoleLoggers() {
|
2016-07-08 06:48:38 +02:00
|
|
|
|
ConsoleLoggingRules.Clear();
|
2018-05-17 09:54:22 +02:00
|
|
|
|
|
2016-09-21 19:26:20 +02:00
|
|
|
|
foreach (LoggingRule loggingRule in LogManager.Configuration.LoggingRules.Where(loggingRule => loggingRule.Targets.Any(target => target is ColoredConsoleTarget || target is ConsoleTarget))) {
|
2016-07-04 22:03:12 +02:00
|
|
|
|
ConsoleLoggingRules.Add(loggingRule);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-07-07 23:27:34 +02:00
|
|
|
|
|
|
|
|
|
|
private static void OnConfigurationChanged(object sender, LoggingConfigurationChangedEventArgs e) {
|
|
|
|
|
|
if ((sender == null) || (e == null)) {
|
2017-01-31 01:10:01 +01:00
|
|
|
|
ASF.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
|
2018-12-15 00:27:15 +01:00
|
|
|
|
|
2016-07-07 23:27:34 +02:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InitConsoleLoggers();
|
2016-07-07 23:36:35 +02:00
|
|
|
|
|
|
|
|
|
|
if (IsWaitingForUserInput) {
|
|
|
|
|
|
OnUserInputStart();
|
|
|
|
|
|
}
|
2018-01-31 02:42:23 +01:00
|
|
|
|
|
2018-07-24 20:43:00 +02:00
|
|
|
|
HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
|
2018-09-08 00:05:23 +02:00
|
|
|
|
ArchiKestrel.OnNewHistoryTarget(historyTarget);
|
2016-07-07 23:27:34 +02:00
|
|
|
|
}
|
2019-02-23 04:31:58 +01:00
|
|
|
|
|
|
|
|
|
|
private static void OnUserInputEnd() {
|
|
|
|
|
|
IsWaitingForUserInput = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (ConsoleLoggingRules.Count == 0) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool reconfigure = false;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (LoggingRule consoleLoggingRule in ConsoleLoggingRules.Where(consoleLoggingRule => !LogManager.Configuration.LoggingRules.Contains(consoleLoggingRule))) {
|
|
|
|
|
|
LogManager.Configuration.LoggingRules.Add(consoleLoggingRule);
|
|
|
|
|
|
reconfigure = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (reconfigure) {
|
|
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void OnUserInputStart() {
|
|
|
|
|
|
IsWaitingForUserInput = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (ConsoleLoggingRules.Count == 0) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool reconfigure = false;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (LoggingRule consoleLoggingRule in ConsoleLoggingRules) {
|
|
|
|
|
|
if (LogManager.Configuration.LoggingRules.Remove(consoleLoggingRule)) {
|
|
|
|
|
|
reconfigure = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (reconfigure) {
|
|
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-06-10 00:49:44 +02:00
|
|
|
|
}
|
2018-09-08 00:05:23 +02:00
|
|
|
|
}
|