public static void LogFile(object log) { if (Conf.DebugMode == Conf.DebugState.None) { return; } if (InternalNGDebug.Platform == RuntimePlatform.WindowsEditor || InternalNGDebug.Platform == RuntimePlatform.OSXEditor || InternalNGDebug.Platform == RuntimePlatform.LinuxEditor) { InternalNGDebug.VerboseLog(log); if (log != null) { try { InternalNGDebug.waitHandle.WaitOne(); int logHash = log.GetHashCode(); if (logHash != InternalNGDebug.lastLogHash) { InternalNGDebug.lastLogHash = logHash; InternalNGDebug.lastLogCounter = 0; File.AppendAllText(InternalNGDebug.LogPath, log + Environment.NewLine); } else { ++InternalNGDebug.lastLogCounter; if (InternalNGDebug.lastLogCounter <= 2) { File.AppendAllText(InternalNGDebug.LogPath, log + Environment.NewLine); } else if (InternalNGDebug.lastLogCounter == 3) { File.AppendAllText(InternalNGDebug.LogPath, "…" + Environment.NewLine); } } } finally { InternalNGDebug.waitHandle.Set(); } } } else { Debug.Log("[" + Constants.PackageTitle + "] " + log); } }
public static void LogFileException(string message, Exception exception) { if (Conf.DebugMode == Conf.DebugState.None) { return; } if (InternalNGDebug.Platform == RuntimePlatform.WindowsEditor || InternalNGDebug.Platform == RuntimePlatform.OSXEditor || InternalNGDebug.Platform == RuntimePlatform.LinuxEditor) { InternalNGDebug.VerboseLog(message); InternalNGDebug.VerboseLogException(exception); try { InternalNGDebug.waitHandle.WaitOne(); int logHash = message.GetHashCode() + exception.GetHashCode(); if (logHash != InternalNGDebug.lastLogHash) { InternalNGDebug.lastLogHash = logHash; InternalNGDebug.lastLogCounter = 0; File.AppendAllText(InternalNGDebug.LogPath, message + Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace + Environment.NewLine); } else { ++InternalNGDebug.lastLogCounter; if (InternalNGDebug.lastLogCounter <= 2) { File.AppendAllText(InternalNGDebug.LogPath, message + Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace + Environment.NewLine); } else if (InternalNGDebug.lastLogCounter == 3) { File.AppendAllText(InternalNGDebug.LogPath, "…" + Environment.NewLine); } } } finally { InternalNGDebug.waitHandle.Set(); } } else { Debug.LogError("[" + Constants.PackageTitle + "] " + message); Debug.LogError("[" + Constants.PackageTitle + "] " + exception.Message + Environment.NewLine + exception.StackTrace); } }