public AddLog ( string condition, string stacktrace, LogType type ) : void | ||
condition | string | |
stacktrace | string | |
type | LogType | |
return | void |
public void OnLogCallBack(string condition, string stacktrace, LogType type) { if (type == LogType.Exception) { errorCount++; } //#if GA // GA.API.Debugging.HandleLog(condition, stacktrace, type); //#endif #if UNITY_WEBPLAYER if (Application.isWebPlayer) { var args = "Unity:" + condition + (type == LogType.Exception ? "\r\n" + stacktrace : ""); Application.ExternalCall("console." + (type == LogType.Exception ? "error" : type == LogType.Log ? "log" : "warn"), args); } #endif reporter.AddLog(condition, stacktrace, type); }
private void ShowLogFromFile(string filename) { logview.clear(); string[] lines = File.ReadAllLines(filename).Where(line => !string.IsNullOrWhiteSpace(line)).ToArray(); int entrystart = -1; for (int i = 0; i < lines.Length; i++) { if (entrystart == -1) { // parse initial section logview.AddLog(lines[i], string.Empty, LogType.Log); if (lines[i].StartsWith("UnloadTime:")) { entrystart = i + 1; } } else { if (i < entrystart) { continue; } // parse log entries // regexes for things unity adds to the log and annoyingly doesn't annotate in any way // shader errors and warnings are thankfully prefixed if (Regex.IsMatch(lines[i], @"ERROR:") || Regex.IsMatch(lines[i], @"^Crash!!!")) { logview.AddLog(lines[i], string.Empty, LogType.Error); entrystart = i + 1; } else if (Regex.IsMatch(lines[i], @"WARNING:") || Regex.IsMatch(lines[i], @"^Fallback handler") || Regex.IsMatch(lines[i], @"^[Dd]3[Dd]") || Regex.IsMatch(lines[i], @"^[uU]ploading [cC]rash [rR]eport")) { logview.AddLog(lines[i], string.Empty, LogType.Warning); entrystart = i + 1; } else if (Regex.IsMatch(lines[i], @"^Unloading.+?[Uu]nused") || Regex.IsMatch(lines[i], @"^System Memory") || Regex.IsMatch(lines[i], @"^Total:.+?CreateObjectMapping") || Regex.IsMatch(lines[i], @"^UnloadTime:") || Regex.IsMatch(lines[i], @"^Log:") || Regex.IsMatch(lines[i], @"^Setting up.+?threads for Enlighten") || Regex.IsMatch(lines[i], @"Thread -> id:")) { logview.AddLog(lines[i], string.Empty, LogType.Log); entrystart = i + 1; } else if (lines[i].StartsWith("(Filename:")) { Entry e = new Entry() { header = lines[entrystart], callstack = lines.Skip(entrystart + 1).Take(i - entrystart - 1).Aggregate(string.Empty, (txt, l) => { txt += l + "\n"; return(txt); }), filename = lines[i] }; entrystart = i + 1; LogEntry(e); } } } }