Ejemplo n.º 1
0
    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;
        }
    }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
    /// <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
    }
Ejemplo n.º 4
0
    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
    }
Ejemplo n.º 5
0
    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
    }