using System; using System.Diagnostics; using System.Runtime.CompilerServices; namespace GlitchyEngine; /// /// Provides methods to log messages to the Engine Console. /// public class Log { /// /// The severity of the log message. /// internal enum LogLevel { Trace = 0, Debug, Info, Warning, Error, Critical, Off } /// /// Logs a trace message. /// /// The message to log. /// File path of the caller. /// Line number of the caller. public static void Trace(string message, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Trace, message, callerFilePath, callerLineNumber); } /// /// Logs an info message. /// /// The message to log. /// File path of the caller. /// Line number of the caller. public static void Info(string message, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Info, message, callerFilePath, callerLineNumber); } /// /// Logs a warning message. /// /// The message to log. /// File path of the caller. /// Line number of the caller. public static void Warning(string message, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Warning, message, callerFilePath, callerLineNumber); } /// /// Logs an error message. /// /// The message to log. /// File path of the caller. /// Line number of the caller. public static void Error(string message, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Error, message, callerFilePath, callerLineNumber); } /// /// Logs a critical error message. /// /// The message to log. /// File path of the caller. /// Line number of the caller. public static void Critical(string message, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Critical, message, callerFilePath, callerLineNumber); } /// /// Serializes the given object (using ) and logs it as a trace message. /// /// The object to serialize. /// File path of the caller. /// Line number of the caller. public static void Trace(object obj, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Trace, obj.ToString(), callerFilePath, callerLineNumber); } /// /// Serializes the given object (using ) and logs it as an info message. /// /// The object to serialize. /// File path of the caller. /// Line number of the caller. public static void Info(object obj, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Info, obj.ToString(), callerFilePath, callerLineNumber); } /// /// Serializes the given object (using ) and logs it as a warning message. /// /// The object to serialize. /// File path of the caller. /// Line number of the caller. public static void Warning(object obj, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Warning, obj.ToString(), callerFilePath, callerLineNumber); } /// /// Serializes the given object (using ) and logs it as an error message. /// /// The object to serialize. /// File path of the caller. /// Line number of the caller. public static void Error(object obj, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Error, obj.ToString(), callerFilePath, callerLineNumber); } /// /// Serializes the given object (using ) and logs it as a critical error message. /// /// The object to serialize. /// File path of the caller. /// Line number of the caller. public static void Critical(object obj, [CallerFilePath]string callerFilePath = "", [CallerLineNumber]int callerLineNumber = 0) { ScriptGlue.Log_LogMessage(LogLevel.Critical, obj.ToString(), callerFilePath, callerLineNumber); } /// /// Logs the give exception. /// /// The exception to log. public static void Exception(Exception exception) { ScriptGlue.Log_LogException(exception); } }