// Constructor public LogMessage(string log, string tag, SMLogType type, string stack) { this.log = log; this.tag = tag; this.type = type; this.stamp = DateTime.Now; this.messageID = ++IDCounter; string[] stackTraces = stack.Split('\n'); int len = stackTraces.Length; stackTrace = new StackTraceEntry[len]; int toAssign = 0; foreach (string trace in stackTraces) { if (trace.Contains("SMConsole.Log") || trace.Contains("get_StackTrace()")) continue; StackTraceEntry entry =new StackTraceEntry(trace, toAssign + 1); if(!entry.isEmpty()) { stackTrace[toAssign] = entry; toAssign++; } } if(toAssign < len) // copy into smaller array { StackTraceEntry[] arr = new StackTraceEntry[toAssign]; for(int i = 0; i < toAssign;i ++) { arr [i] = stackTrace[i]; } stackTrace = arr; } }
private void DrawList() { Rect scrollViewRect = new Rect() { y = _listRect.y, height = _listRect.height, width = _listRect.width, }; Rect position = new Rect() { height = _target.StackTraces.Count * LINE_HEIGHT, width = scrollViewRect.width - 20, }; _listScrollPosition = GUI.BeginScrollView(scrollViewRect, _listScrollPosition, position); for (int i = 0; i < _target.StackTraces.Count; i++) { StackTraceEntry currentTrace = _target.StackTraces[i]; string currentText = GetFirstLine(currentTrace); Rect elementRect = new Rect() { width = _listRect.width, height = LINE_HEIGHT, y = i * LINE_HEIGHT, }; if (Event.current.type == EventType.MouseDown && elementRect.Contains(Event.current.mousePosition)) { _selectedTrace = currentTrace; Repaint(); } else if (Event.current.type == EventType.Repaint) { bool isSelected = _selectedTrace == currentTrace; GUIStyle backgroundStyle = i % 2 == 0 ? Styles.EvenBackground : Styles.OddBackground; backgroundStyle.Draw(elementRect, false, false, isSelected, false); Styles.Text.Draw(elementRect, new GUIContent(currentText), 0); } } GUI.EndScrollView(); }
private void ProcessNewException(string line, long lineNumber) { Regex exceptionStart = new Regex("Caught Exception:\\s+(.*?)\\s+\\(\\d+,\\d+\\)\\s+(.*)"); var match = exceptionStart.Match(line); if (match.Success) { _processingException = true; currentStackTrace = new StackTraceEntry(); currentStackTrace.LineNumber = lineNumber; currentStackTrace.Message = match.Groups[1].Value; currentStackTrace.Offender = match.Groups[2].Value; StackTraces.Add(currentStackTrace); } }
private void DeserializeStackTraces() { /* StackTraceEntry Layout * InternalID - Uint * Message - string * Offender - string * StackTrace - list of strings (in order) * Parent is Present - bool * Parent Call - InternalID */ /* get count of items */ var totalCount = ReadUint(); for (var x = 0; x < totalCount; x++) { /* read each item */ StackTraceEntry item = new StackTraceEntry(); Data.StackTraces.Add(item); item.InternalID = ReadUint(); item.Message = ReadString(); item.Offender = ReadString(); var traceLineCount = ReadUint(); for (var y = 0; y < traceLineCount; y++) { item.StackTrace.Add(ReadString()); } var parentPresent = ReadBool(); if (parentPresent) { StacksToResolve.Add(item, ReadUint()); } } }
private void Deselect() { _selectedTrace = null; }
public void AddStackTrace() { #if UNITY_EDITOR StackTraces.Insert(0, StackTraceEntry.Create()); #endif }