From ae05e0ffab9c74f71a38a95e418dd9467e3a2321 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 24 Jul 2018 20:43:00 +0200 Subject: [PATCH] Extra misc fixes --- ArchiSteamFarm/IPC.cs | 13 +++++-------- ArchiSteamFarm/Logging.cs | 17 ++++------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/ArchiSteamFarm/IPC.cs b/ArchiSteamFarm/IPC.cs index 7bb5ecddf..da440d023 100644 --- a/ArchiSteamFarm/IPC.cs +++ b/ArchiSteamFarm/IPC.cs @@ -84,19 +84,16 @@ namespace ArchiSteamFarm { private static HttpListener HttpListener; private static bool IsHandlingRequests; - internal static void OnNewHistoryTarget(HistoryTarget historyTarget) { - if (historyTarget == null) { - ASF.ArchiLogger.LogNullError(nameof(historyTarget)); - return; - } - + internal static void OnNewHistoryTarget(HistoryTarget historyTarget = null) { if (HistoryTarget != null) { HistoryTarget.NewHistoryEntry -= OnNewHistoryEntry; HistoryTarget = null; } - historyTarget.NewHistoryEntry += OnNewHistoryEntry; - HistoryTarget = historyTarget; + if (historyTarget != null) { + historyTarget.NewHistoryEntry += OnNewHistoryEntry; + HistoryTarget = historyTarget; + } } internal static void Start(HashSet prefixes) { diff --git a/ArchiSteamFarm/Logging.cs b/ArchiSteamFarm/Logging.cs index e1d4cd5ec..6c6dbc5de 100644 --- a/ArchiSteamFarm/Logging.cs +++ b/ArchiSteamFarm/Logging.cs @@ -84,15 +84,9 @@ namespace ArchiSteamFarm { return; } - HistoryTarget historyTarget; + HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType().FirstOrDefault(); - if (IsUsingCustomConfiguration) { - historyTarget = LogManager.Configuration.AllTargets.OfType().FirstOrDefault(); - - if (historyTarget == null) { - return; - } - } else { + if ((historyTarget == null) && !IsUsingCustomConfiguration) { // TODO: We could use some nice HTML layout for this historyTarget = new HistoryTarget("History") { Layout = GeneralLayout, @@ -167,11 +161,8 @@ namespace ArchiSteamFarm { OnUserInputStart(); } - HistoryTarget historyTarget = (HistoryTarget) LogManager.Configuration.AllTargets.FirstOrDefault(target => target is HistoryTarget); - - if (historyTarget != null) { - IPC.OnNewHistoryTarget(historyTarget); - } + HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType().FirstOrDefault(); + IPC.OnNewHistoryTarget(historyTarget); } } }