From 69d6d6e10b970527d9290a42700b52905dc131e8 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Mon, 4 Jul 2016 22:46:08 +0200 Subject: [PATCH] Use ASF instead of Main for global logging routines, closes #280 --- ArchiSteamFarm/Logging.cs | 14 +++++++------- ArchiSteamFarm/Program.cs | 7 +++---- ConfigGenerator/MainForm.cs | 2 -- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ArchiSteamFarm/Logging.cs b/ArchiSteamFarm/Logging.cs index 14f4640a1..6a8ee78c6 100644 --- a/ArchiSteamFarm/Logging.cs +++ b/ArchiSteamFarm/Logging.cs @@ -114,7 +114,7 @@ namespace ArchiSteamFarm { LogManager.ReconfigExistingLoggers(); } - internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogGenericError(string message, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (string.IsNullOrEmpty(message)) { LogNullError(nameof(message), botName); return; @@ -123,7 +123,7 @@ namespace ArchiSteamFarm { Logger.Error($"{botName}|{previousMethodName}() {message}"); } - internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogGenericException(Exception exception, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (exception == null) { LogNullError(nameof(exception), botName); return; @@ -132,7 +132,7 @@ namespace ArchiSteamFarm { Logger.Error(exception, $"{botName}|{previousMethodName}()"); } - internal static void LogFatalException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogFatalException(Exception exception, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (exception == null) { LogNullError(nameof(exception), botName); return; @@ -141,7 +141,7 @@ namespace ArchiSteamFarm { Logger.Fatal(exception, $"{botName}|{previousMethodName}()"); } - internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogGenericWarning(string message, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (string.IsNullOrEmpty(message)) { LogNullError(nameof(message), botName); return; @@ -150,7 +150,7 @@ namespace ArchiSteamFarm { Logger.Warn($"{botName}|{previousMethodName}() {message}"); } - internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogGenericInfo(string message, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (string.IsNullOrEmpty(message)) { LogNullError(nameof(message), botName); return; @@ -160,7 +160,7 @@ namespace ArchiSteamFarm { } [SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")] - internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogNullError(string nullObjectName, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (string.IsNullOrEmpty(nullObjectName)) { return; } @@ -170,7 +170,7 @@ namespace ArchiSteamFarm { [Conditional("DEBUG")] [SuppressMessage("ReSharper", "UnusedMember.Global")] - internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) { + internal static void LogGenericDebug(string message, string botName = Program.ASF, [CallerMemberName] string previousMethodName = null) { if (string.IsNullOrEmpty(message)) { LogNullError(nameof(message), botName); return; diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 1119cbf41..9f94624ea 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -59,11 +59,11 @@ namespace ArchiSteamFarm { Server // Normal + WCF server } + internal const string ASF = "ASF"; internal const string ConfigDirectory = "config"; internal const string DebugDirectory = "debug"; internal const string LogFile = "log.txt"; - private const string ASF = "ASF"; private const string GithubReleaseURL = "https://api.github.com/repos/" + SharedInfo.GithubRepo + "/releases"; // GitHub API is HTTPS only private const string GlobalConfigFile = ASF + ".json"; private const string GlobalDatabaseFile = ASF + ".db"; @@ -274,7 +274,7 @@ namespace ArchiSteamFarm { Exit(); } - internal static string GetUserInput(EUserInputType userInputType, string botName = "Main", string extraInformation = null) { + internal static string GetUserInput(EUserInputType userInputType, string botName = ASF, string extraInformation = null) { if (userInputType == EUserInputType.Unknown) { return null; } @@ -386,7 +386,7 @@ namespace ArchiSteamFarm { WebBrowser.Init(); WCF.Init(); - WebBrowser = new WebBrowser("Main"); + WebBrowser = new WebBrowser(ASF); } private static void ParseArgs(IEnumerable args) { @@ -522,7 +522,6 @@ namespace ArchiSteamFarm { foreach (string botName in Directory.EnumerateFiles(ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) { switch (botName) { case ASF: - case "Main": case "example": case "minimal": continue; diff --git a/ConfigGenerator/MainForm.cs b/ConfigGenerator/MainForm.cs index bb5048495..4401d8aac 100644 --- a/ConfigGenerator/MainForm.cs +++ b/ConfigGenerator/MainForm.cs @@ -60,7 +60,6 @@ namespace ConfigGenerator { string botName = Path.GetFileNameWithoutExtension(configFile); switch (botName) { case Program.ASF: - case "Main": case "example": case "minimal": continue; @@ -163,7 +162,6 @@ namespace ConfigGenerator { switch (input) { case Program.ASF: - case "Main": case "example": case "minimal": Logging.LogGenericErrorWithoutStacktrace("This name is reserved!");