private string FormatLine(string line, LogLevel level, Tag tag, string stackTrace) { RecyclableStringBuilder lineBuffer = StringBuilderPool.NextBuilder(); string coloredLine = EditorSkin.SetColors(line); string filename = EditorStackTrace.ExtractFileName(stackTrace); if (level != null) { lineBuffer.Append("["); lineBuffer.Append(level.ShortName); lineBuffer.Append("]: "); } if (filename != null) { lineBuffer.Append(StringUtils.C("[" + filename + "]: ", EditorSkin.GetColor(ColorCode.Plain))); } if (tag != null) { lineBuffer.Append("["); lineBuffer.Append(tag.Name); lineBuffer.Append("]: "); } lineBuffer.Append(coloredLine); string result = lineBuffer.ToString(); lineBuffer.Recycle(); // don't trash timer manager with this call return(result); }
private static void ResolveSourceLink(GUIStyleTextMeasure measure, ref StackTraceLine stackLine) { Color color = EditorSkin.GetColor(stackLine.sourcePathExists ? ColorCode.Link : ColorCode.LinkInnactive); int sourceStart = stackLine.sourcePathStart; int sourceEnd = stackLine.sourcePathEnd; GUIStyle style = measure.Style; GUIContent content = new GUIContent(stackLine.line); float startPosX = style.GetCursorPixelPosition(stackLine.frame, content, sourceStart).x - 1; float endPosX = style.GetCursorPixelPosition(stackLine.frame, content, sourceEnd).x + 1; stackLine.sourceFrame = new Rect(startPosX, stackLine.frame.y, endPosX - startPosX, stackLine.frame.height); stackLine.line = StringUtils.C(stackLine.line, color, sourceStart, sourceEnd); }
////////////////////////////////////////////////////////////////////////////// private TableViewCell CreateTableCell(TableView table, ref ConsoleViewCellEntry entry) { if (entry.IsPlain || entry.IsTable) { ConsoleTextEntryView cell; if (entry.level == LogLevel.Exception) { ConsoleTextEntryExceptionView exceptionCell = table.DequeueReusableCell <ConsoleTextEntryExceptionView>(); if (exceptionCell == null) { exceptionCell = new ConsoleTextEntryExceptionView(); } exceptionCell.StackTraceLines = entry.data as StackTraceLine[]; cell = exceptionCell; } else { cell = table.DequeueReusableCell <ConsoleTextEntryView>(); if (cell == null) { cell = new ConsoleTextEntryView(); } } // set the size first to calculate individual lines height ColorCode colorCode = entry.level != null ? entry.level.Color : ColorCode.Plain; cell.TextColor = EditorSkin.GetColor(colorCode); cell.Width = entry.width; cell.Height = entry.height; cell.Value = entry.value; cell.LogLevel = entry.level; cell.StackTrace = entry.stackTrace; return(cell); } else { throw new NotImplementedException("Unexpected entry type"); } }