Use ASF instead of Main for global logging routines, closes #280

This commit is contained in:
JustArchi
2016-07-04 22:46:08 +02:00
parent 38eb130217
commit 69d6d6e10b
3 changed files with 10 additions and 13 deletions

View File

@@ -114,7 +114,7 @@ namespace ArchiSteamFarm {
LogManager.ReconfigExistingLoggers(); 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)) { if (string.IsNullOrEmpty(message)) {
LogNullError(nameof(message), botName); LogNullError(nameof(message), botName);
return; return;
@@ -123,7 +123,7 @@ namespace ArchiSteamFarm {
Logger.Error($"{botName}|{previousMethodName}() {message}"); 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) { if (exception == null) {
LogNullError(nameof(exception), botName); LogNullError(nameof(exception), botName);
return; return;
@@ -132,7 +132,7 @@ namespace ArchiSteamFarm {
Logger.Error(exception, $"{botName}|{previousMethodName}()"); 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) { if (exception == null) {
LogNullError(nameof(exception), botName); LogNullError(nameof(exception), botName);
return; return;
@@ -141,7 +141,7 @@ namespace ArchiSteamFarm {
Logger.Fatal(exception, $"{botName}|{previousMethodName}()"); 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)) { if (string.IsNullOrEmpty(message)) {
LogNullError(nameof(message), botName); LogNullError(nameof(message), botName);
return; return;
@@ -150,7 +150,7 @@ namespace ArchiSteamFarm {
Logger.Warn($"{botName}|{previousMethodName}() {message}"); 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)) { if (string.IsNullOrEmpty(message)) {
LogNullError(nameof(message), botName); LogNullError(nameof(message), botName);
return; return;
@@ -160,7 +160,7 @@ namespace ArchiSteamFarm {
} }
[SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")] [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)) { if (string.IsNullOrEmpty(nullObjectName)) {
return; return;
} }
@@ -170,7 +170,7 @@ namespace ArchiSteamFarm {
[Conditional("DEBUG")] [Conditional("DEBUG")]
[SuppressMessage("ReSharper", "UnusedMember.Global")] [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)) { if (string.IsNullOrEmpty(message)) {
LogNullError(nameof(message), botName); LogNullError(nameof(message), botName);
return; return;

View File

@@ -59,11 +59,11 @@ namespace ArchiSteamFarm {
Server // Normal + WCF server Server // Normal + WCF server
} }
internal const string ASF = "ASF";
internal const string ConfigDirectory = "config"; internal const string ConfigDirectory = "config";
internal const string DebugDirectory = "debug"; internal const string DebugDirectory = "debug";
internal const string LogFile = "log.txt"; 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 GithubReleaseURL = "https://api.github.com/repos/" + SharedInfo.GithubRepo + "/releases"; // GitHub API is HTTPS only
private const string GlobalConfigFile = ASF + ".json"; private const string GlobalConfigFile = ASF + ".json";
private const string GlobalDatabaseFile = ASF + ".db"; private const string GlobalDatabaseFile = ASF + ".db";
@@ -274,7 +274,7 @@ namespace ArchiSteamFarm {
Exit(); 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) { if (userInputType == EUserInputType.Unknown) {
return null; return null;
} }
@@ -386,7 +386,7 @@ namespace ArchiSteamFarm {
WebBrowser.Init(); WebBrowser.Init();
WCF.Init(); WCF.Init();
WebBrowser = new WebBrowser("Main"); WebBrowser = new WebBrowser(ASF);
} }
private static void ParseArgs(IEnumerable<string> args) { private static void ParseArgs(IEnumerable<string> args) {
@@ -522,7 +522,6 @@ namespace ArchiSteamFarm {
foreach (string botName in Directory.EnumerateFiles(ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) { foreach (string botName in Directory.EnumerateFiles(ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
switch (botName) { switch (botName) {
case ASF: case ASF:
case "Main":
case "example": case "example":
case "minimal": case "minimal":
continue; continue;

View File

@@ -60,7 +60,6 @@ namespace ConfigGenerator {
string botName = Path.GetFileNameWithoutExtension(configFile); string botName = Path.GetFileNameWithoutExtension(configFile);
switch (botName) { switch (botName) {
case Program.ASF: case Program.ASF:
case "Main":
case "example": case "example":
case "minimal": case "minimal":
continue; continue;
@@ -163,7 +162,6 @@ namespace ConfigGenerator {
switch (input) { switch (input) {
case Program.ASF: case Program.ASF:
case "Main":
case "example": case "example":
case "minimal": case "minimal":
Logging.LogGenericErrorWithoutStacktrace("This name is reserved!"); Logging.LogGenericErrorWithoutStacktrace("This name is reserved!");