Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed May 6, 2016
1 parent 38e2088 commit f1e5874
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions ArchiSteamFarm/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ internal static void Init() {

if (LogToFile) {
lock (FileLock) {
if (!LogToFile) {
return;
}

try {
File.Delete(Program.LogFile);
} catch (Exception e) {
Expand All @@ -48,23 +52,23 @@ internal static void Init() {
}
}

internal static void LogGenericWTF(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogGenericWTF(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(message)) {
return;
}

Log("[!!] WTF: " + previousMethodName + "() <" + botName + "> " + message + ", WTF?");
}

internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(message)) {
return;
}

Log("[!!] ERROR: " + previousMethodName + "() <" + botName + "> " + message);
}

internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (exception == null) {
return;
}
Expand All @@ -77,23 +81,23 @@ internal static void LogGenericException(Exception exception, string botName = "
}
}

internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(message)) {
return;
}

Log("[!] WARNING: " + previousMethodName + "() <" + botName + "> " + message);
}

internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(message)) {
return;
}

Log("[*] INFO: " + previousMethodName + "() <" + botName + "> " + message);
}

internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(nullObjectName)) {
return;
}
Expand All @@ -102,7 +106,7 @@ internal static void LogNullError(string nullObjectName, string botName = "Main"
}

[Conditional("DEBUG")]
internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
if (string.IsNullOrEmpty(message)) {
return;
}
Expand All @@ -126,6 +130,10 @@ private static void Log(string message) {

if (LogToFile) {
lock (FileLock) {
if (!LogToFile) {
return;
}

try {
File.AppendAllText(Program.LogFile, loggedMessage);
} catch (Exception e) {
Expand Down

0 comments on commit f1e5874

Please sign in to comment.