using System.Diagnostics; using System.IO; namespace Awperative; public static partial class Debug { /// /// Writes the current message to the log file. /// /// Message to debug public static void LogState(string __message) => LogGeneric(__message, "STA", [], []); /// /// Writes the current message to the log file. With any given call sign. /// /// Message to debug /// Names of values to debug /// Values to debug public static void LogState(string __message, string[] __parameters, string[] __values) => LogGeneric(__message, "STA", __parameters, __values); /// /// Writes the current message to the log file. /// /// Message to debug public static void LogValue(string __message) => LogGeneric(__message, "VAL", [], []); /// /// Writes the current message to the log file. With any given call sign. /// /// Message to debug /// Names of values to debug /// Values to debug public static void LogValue(string __message, string[] __parameters, string[] __values) => LogGeneric(__message, "VAL", __parameters, __values); /// /// Writes the current message to the log file. /// /// Message to debug public static void LogWarning(string __message) => LogGeneric(__message, "WAR", [], []); /// /// Writes the current message to the log file. With any given call sign. /// /// Message to debug /// Names of values to debug /// Values to debug public static void LogWarning(string __message, string[] __parameters, string[] __values) => LogGeneric(__message, "WAR", __parameters, __values); /// /// Writes the current message to the log file. /// /// Message to debug public static void LogError(string __message) => LogGeneric(__message, "ERR", [], []); /// /// Writes the current message to the log file. With any given call sign. /// /// Message to debug /// Names of values to debug /// Values to debug public static void LogError(string __message, string[] __parameters, string[] __values) => LogGeneric(__message, "ERR", __parameters, __values); /// /// Writes the current message to the log file. /// /// Message to debug /// Condition to debug public static void AssertError(bool __condition, string __message) => AssertGeneric(__condition, __message, "ERR", [], []); //todo: add more asserts and overrides /// /// Writes the current message to the log file. With any given call sign. /// /// Message to debug /// Message identifier /// Names of values to debug /// Values to debug public static void LogGeneric(string __message, string __callSign, string[] __parameters, string[] __values) { string output = "\n\n" + __callSign + "- \"" + __message + "\"\n STK-" + new StackTrace(); for (int i = 0; i < __parameters.Length || i < __values.Length; i++) output += "\n " + __parameters[i] + "- " + __values[i]; File.AppendAllText(LogFilePath, output); } public static void AssertGeneric(bool __condition, string __message, string __callSign, string[] __parameters, string[] __values) { if (!__condition) return; string output = "\n\n" + __callSign + "- \"" + __message + "\"\n STK-" + new StackTrace(); for (int i = 0; i < __parameters.Length || i < __values.Length; i++) output += "\n " + __parameters[i] + "- " + __values[i]; File.AppendAllText(LogFilePath, output); } }