public static void Debug(string log, eLogLevel logLevel, eLogOutputType outputType = eLogOutputType.All, string path = null, bool stackTrace = false) { switch (logLevel) { case eLogLevel.Error: Error(log, eLogColor.Red, outputType, path, stackTrace); break; case eLogLevel.Exception: Error(log, eLogColor.Red, outputType, path, stackTrace); break; case eLogLevel.Log: Debug(log, eLogColor.White, outputType, path, stackTrace); break; case eLogLevel.Warning: Warning(log, eLogColor.Yellow, outputType, path, stackTrace); break; case eLogLevel.Assert: Error(log, eLogColor.Red, outputType, path, stackTrace); break; } }
public LogUnit(eLogLevel logLevel, string log, string stackTrace = null, eLogOutputType outputType = eLogOutputType.All, string savePath = null, eLogColor color = eLogColor.Default) { LogLevel = logLevel; Log = log; StackTrace = stackTrace; OutputType = outputType; Timer = DateTime.Now; SavePath = savePath; Color = color; }
/// <summary>初始化</summary> /// <param name="logDirectory">文件夹</param> public static void Init(string logDirectory, bool enable, eLogOutputType outputType = eLogOutputType.Txt) { _limitOutputType = outputType; SetEnable(enable); LogDirectory = logDirectory; LogPath = Path.Combine(LogDirectory, DateTime.Now.ToString(TIME_FORMAT_YMDHMS)); #if !CSHARP_LOGIC UnityEngine.Application.logMessageReceived += onLogMessageReceivedHandler; #if UNITY_EDITOR UnityEngine.Debug.Log($"logPath:{LogPath}"); UnityEditor.EditorApplication.playModeStateChanged -= onPlayModeStateChangedHandler; UnityEditor.EditorApplication.playModeStateChanged += onPlayModeStateChangedHandler; #endif #endif }
public static void WriteLog(string log, string stackTrace = null, eLogLevel logLevel = eLogLevel.Log, eLogOutputType outputType = eLogOutputType.All, eLogColor logColor = eLogColor.Default, string savePath = null) { #if DEBUG_LOG || LOG_ONLY_EXCEPTION || UNITY_EDITOR WriteLog(new LogUnit(logLevel, log, stackTrace, outputType, savePath, logColor)); #endif }
public static void Error(string log, eLogColor logColor = eLogColor.Red, eLogOutputType outputType = eLogOutputType.All, string path = null, bool stackTrace = false) { #if DEBUG_LOG || LOG_ONLY_EXCEPTION || UNITY_EDITOR WriteLog(log, !stackTrace ? string.Empty : new System.Diagnostics.StackTrace().ToString(), eLogLevel.Error, outputType, logColor, path); #endif }