using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Diagnostics; namespace CLre_server.API.Utility { /// /// Utility class to access Cardlife's built-in logging capabilities. /// The log is saved to outputLog#.Log /// public static class Logging { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Log(string msg) { Svelto.Console.Log(msg); } /// /// Write a regular message to Cardlife's log /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Log(object obj) { Svelto.Console.Log(obj.ToString()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogError(string msg, Dictionary extraData = null) { Svelto.Console.LogError(msg, extraData); } /// /// Write an error message to Cardlife's log /// /// The object to log /// The extra data to pass to the ILogger [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogError(object obj, Dictionary extraData = null) { Svelto.Console.LogError(obj.ToString(), extraData); } /// /// Write an exception to Cardlife's log and to the screen and exit game /// /// The exception to log /// The extra data to pass to the ILogger. /// This is automatically populated with "OuterException#" and "OuterStacktrace#" entries [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogException(Exception e, string msg = null, Dictionary extraData = null) { Svelto.Console.LogException(msg, e, extraData); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogWarning(string msg) { Svelto.Console.LogWarning(msg); } /// /// Write a warning message to Cardlife's log /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogWarning(object obj) { Svelto.Console.LogWarning(obj.ToString()); } // descriptive logging /// /// Write a descriptive message to Cardlife's log including the calling method's name /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MetaLog(object obj) { var method = (new StackTrace()).GetFrame(1).GetMethod(); Log($"[{method.DeclaringType.FullName}.{method.Name}] {obj.ToString()}"); } } }