private void SetText(DebugLogEntry logEntry, DebugLogEntryTimestamp?logEntryTimestamp, bool isExpanded) { if (!logEntryTimestamp.HasValue || (!isExpanded && !listView.manager.alwaysDisplayTimestamps)) { logText.text = isExpanded ? logEntry.ToString() : logEntry.logString; } else { StringBuilder sb = listView.manager.sharedStringBuilder; sb.Length = 0; if (isExpanded) { logEntryTimestamp.Value.AppendFullTimestamp(sb); sb.Append(": ").Append(logEntry.ToString()); } else { logEntryTimestamp.Value.AppendTime(sb); sb.Append(" ").Append(logEntry.logString); } logText.text = sb.ToString(); } }
public void SetContent(DebugLogEntry logEntry, int entryIndex, bool isExpanded) { this.logEntry = logEntry; this.entryIndex = entryIndex; Vector2 size = transformComponent.sizeDelta; if (isExpanded) { logText.horizontalOverflow = HorizontalWrapMode.Wrap; size.y = manager.SelectedItemHeight; //logText.rectTransform.anchoredPosition = logTextOriginalPosition; //logText.rectTransform.sizeDelta = logTextOriginalSize; } else { logText.horizontalOverflow = HorizontalWrapMode.Overflow; size.y = manager.ItemHeight; //logText.rectTransform.anchoredPosition = logTextOriginalPosition; //logText.rectTransform.sizeDelta = logTextOriginalSize; } transformComponent.sizeDelta = size; logText.text = isExpanded ? logEntry.ToString() : logEntry.logString; logTypeImage.sprite = logEntry.logTypeSpriteRepresentation; }
private void FilterLogs(string str) { if (isCollapseOn) { // All the unique debug entries will be listed just once. // So, list of debug entries to show is the same as the // order these unique debug entries are added to collapsedLogEntries indicesOfListEntriesToShow.Clear(); for (int i = 0; i < collapsedLogEntries.Count; i++) { if (IsMatch(collapsedLogEntries[i])) { indicesOfListEntriesToShow.Add(i); } } } else { indicesOfListEntriesToShow.Clear(); for (int i = 0; i < uncollapsedLogEntriesIndices.Count; i++) { DebugLogEntry logEntry = collapsedLogEntries[uncollapsedLogEntriesIndices[i]]; if (IsMatch(logEntry)) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } } } // Update the recycled list view recycledListView.DeselectSelectedLogItem(); recycledListView.OnLogEntriesUpdated(true); ValidateScrollPosition(); }
public void SetContent(DebugLogEntry logEntry, int entryIndex) { this.logEntry = logEntry; this.entryIndex = entryIndex; logText.text = logEntry.logString; logTypeImage.sprite = logEntry.logTypeSpriteRepresentation; }
public float CalculateExpandedHeight(DebugLogEntry logEntry, DebugLogEntryTimestamp?logEntryTimestamp) { string text = logText.text; HorizontalWrapMode wrapMode = logText.horizontalOverflow; SetText(logEntry, logEntryTimestamp, true); logText.horizontalOverflow = HorizontalWrapMode.Wrap; float result = logText.preferredHeight + copyLogButtonHeight; logText.text = text; logText.horizontalOverflow = wrapMode; return(Mathf.Max(listView.ItemHeight, result)); }
public void SetContent(DebugLogEntry logEntry, DebugLogEntryTimestamp?logEntryTimestamp, int entryIndex, bool isExpanded) { this.logEntry = logEntry; this.logEntryTimestamp = logEntryTimestamp; this.entryIndex = entryIndex; this.isExpanded = isExpanded; Vector2 size = transformComponent.sizeDelta; if (isExpanded) { logText.horizontalOverflow = HorizontalWrapMode.Wrap; size.y = listView.SelectedItemHeight; if (!copyLogButton.gameObject.activeSelf) { copyLogButton.gameObject.SetActive(true); logText.rectTransform.anchoredPosition = new Vector2(logTextOriginalPosition.x, logTextOriginalPosition.y + copyLogButtonHeight * 0.5f); logText.rectTransform.sizeDelta = logTextOriginalSize - new Vector2(0f, copyLogButtonHeight); } } else { logText.horizontalOverflow = HorizontalWrapMode.Overflow; size.y = listView.ItemHeight; if (copyLogButton.gameObject.activeSelf) { copyLogButton.gameObject.SetActive(false); logText.rectTransform.anchoredPosition = logTextOriginalPosition; logText.rectTransform.sizeDelta = logTextOriginalSize; } } transformComponent.sizeDelta = size; SetText(logEntry, logEntryTimestamp, isExpanded); logTypeImage.sprite = logEntry.logTypeSpriteRepresentation; }
public void SetContent(DebugLogEntry logEntry, int entryIndex, bool isExpanded) { this.logEntry = logEntry; this.entryIndex = entryIndex; Vector2 size = transformComponent.sizeDelta; if (isExpanded) { logText.horizontalOverflow = HorizontalWrapMode.Wrap; size.y = manager.SelectedItemHeight; if (!copyLogButton.gameObject.activeSelf) { copyLogButton.gameObject.SetActive(true); logText.rectTransform.anchoredPosition = new Vector2(logTextOriginalPosition.x, logTextOriginalPosition.y + copyLogButtonHeight * 0.5f); logText.rectTransform.sizeDelta = logTextOriginalSize - new Vector2(0f, copyLogButtonHeight); } } else { logText.horizontalOverflow = HorizontalWrapMode.Overflow; size.y = manager.ItemHeight; if (copyLogButton.gameObject.activeSelf) { copyLogButton.gameObject.SetActive(false); logText.rectTransform.anchoredPosition = logTextOriginalPosition; logText.rectTransform.sizeDelta = logTextOriginalSize; } } transformComponent.sizeDelta = size; logText.text = isExpanded ? logEntry.ToString() : logEntry.logString; DebuMessage = isExpanded ? logEntry.ToString() : logEntry.logString; logTypeImage.sprite = logEntry.logTypeSpriteRepresentation; DebugDisplay.OnDebugMessageDisplayed?.Invoke(DebuMessage, logEntry.logTypeSpriteRepresentation); }
public string GetAllLogs() { int count = uncollapsedLogEntriesIndices.Count; int length = 0; int newLineLength = System.Environment.NewLine.Length; for( int i = 0; i < count; i++ ) { DebugLogEntry entry = collapsedLogEntries[uncollapsedLogEntriesIndices[i]]; length += entry.logString.Length + entry.stackTrace.Length + newLineLength * 3; } length += 100; // Just in case... System.Text.StringBuilder sb = new System.Text.StringBuilder( length ); for( int i = 0; i < count; i++ ) { DebugLogEntry entry = collapsedLogEntries[uncollapsedLogEntriesIndices[i]]; sb.AppendLine( entry.logString ).AppendLine( entry.stackTrace ).AppendLine(); } return sb.ToString(); }
public void SetContent(DebugLogEntry logEntry, int entryIndex, bool isExpanded) { this.logEntry = logEntry; this.entryIndex = entryIndex; Vector2 size = transformComponent.sizeDelta; if (isExpanded) { //logText.horizontalOverflow = HorizontalWrapMode.Wrap; size.y = manager.SelectedItemHeight; } else { //logText.horizontalOverflow = HorizontalWrapMode.Wrap; //size.y = CalculateExpandedHeight(logEntry.logString); size.y = manager.ItemHeight; } transformComponent.sizeDelta = size; logText.text = isExpanded ? logEntry.ToString() : logEntry.logString; logTypeImage.sprite = logEntry.logTypeSpriteRepresentation; }
public void SetContent(DebugLogEntry logEntry, int entryIndex, bool isExpanded) { this.logEntry = logEntry; Index = entryIndex; var size = Transform.sizeDelta; if (isExpanded) { logText.horizontalOverflow = HorizontalWrapMode.Wrap; size.y = manager.SelectedItemHeight; } else { logText.horizontalOverflow = HorizontalWrapMode.Overflow; size.y = manager.ItemHeight; } Transform.sizeDelta = size; logText.text = isExpanded ? logEntry.ToString() : logEntry.logString; logTypeImage.sprite = logEntry.logTypeSpriteRepresentation; }
// A debug entry is received private void ReceivedLog(string logString, string stackTrace, LogType logType) { if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { // Trying to update the UI while the canvas is being rebuilt will throw warnings in the Unity console queuedLogs.Add(new QueuedDebugLogEntry(logString, stackTrace, logType)); return; } DebugLogEntry logEntry = new DebugLogEntry(logString, stackTrace, null); // Check if this entry is a duplicate (i.e. has been received before) int logEntryIndex; bool isEntryInCollapsedEntryList = collapsedLogEntriesMap.TryGetValue(logEntry, out logEntryIndex); if (!isEntryInCollapsedEntryList) { // It is not a duplicate, // add it to the list of unique debug entries logEntry.logTypeSpriteRepresentation = logSpriteRepresentations[logType]; logEntryIndex = collapsedLogEntries.Count; collapsedLogEntries.Add(logEntry); collapsedLogEntriesMap[logEntry] = logEntryIndex; } else { // It is a duplicate, // increment the original debug item's collapsed count logEntry = collapsedLogEntries[logEntryIndex]; logEntry.count++; } // Add the index of the unique debug entry to the list // that stores the order the debug entries are received uncollapsedLogEntriesIndices.Add(logEntryIndex); // If this debug entry matches the current filters, // add it to the list of debug entries to show Sprite logTypeSpriteRepresentation = logEntry.logTypeSpriteRepresentation; if (isCollapseOn && isEntryInCollapsedEntryList) { if (isLogWindowVisible) { recycledListView.OnCollapsedLogEntryAtIndexUpdated(logEntryIndex); } } else if (logFilter == DebugLogFilter.All || (logTypeSpriteRepresentation == infoLog && ((logFilter & DebugLogFilter.Info) == DebugLogFilter.Info)) || (logTypeSpriteRepresentation == warningLog && ((logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning)) || (logTypeSpriteRepresentation == errorLog && ((logFilter & DebugLogFilter.Error) == DebugLogFilter.Error))) { indicesOfListEntriesToShow.Add(logEntryIndex); if (isLogWindowVisible) { recycledListView.OnLogEntriesUpdated(false); } } if (logType == LogType.Log) { infoEntryCount++; infoEntryCountText.text = infoEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewInfoLogArrived(); } } else if (logType == LogType.Warning) { warningEntryCount++; warningEntryCountText.text = warningEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewWarningLogArrived(); } } else { errorEntryCount++; errorEntryCountText.text = errorEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewErrorLogArrived(); } } }
// Determine the filtered list of debug entries to show on screen private void FilterLogs() { if (logFilter == DebugLogFilter.None) { // Show no entry indicesOfListEntriesToShow.Clear(); } else if (logFilter == DebugLogFilter.All) { if (isCollapseOn) { // All the unique debug entries will be listed just once. // So, list of debug entries to show is the same as the // order these unique debug entries are added to collapsedLogEntries indicesOfListEntriesToShow.Clear(); for (int i = 0; i < collapsedLogEntries.Count; i++) { indicesOfListEntriesToShow.Add(i); } } else { indicesOfListEntriesToShow.Clear(); for (int i = 0; i < uncollapsedLogEntriesIndices.Count; i++) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } } } else { // Show only the debug entries that match the current filter bool isInfoEnabled = (logFilter & DebugLogFilter.Info) == DebugLogFilter.Info; bool isWarningEnabled = (logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning; bool isErrorEnabled = (logFilter & DebugLogFilter.Error) == DebugLogFilter.Error; if (isCollapseOn) { indicesOfListEntriesToShow.Clear(); for (int i = 0; i < collapsedLogEntries.Count; i++) { DebugLogEntry logEntry = collapsedLogEntries[i]; if (logEntry.logTypeSpriteRepresentation == infoLog && isInfoEnabled) { indicesOfListEntriesToShow.Add(i); } else if (logEntry.logTypeSpriteRepresentation == warningLog && isWarningEnabled) { indicesOfListEntriesToShow.Add(i); } else if (logEntry.logTypeSpriteRepresentation == errorLog && isErrorEnabled) { indicesOfListEntriesToShow.Add(i); } } } else { indicesOfListEntriesToShow.Clear(); for (int i = 0; i < uncollapsedLogEntriesIndices.Count; i++) { DebugLogEntry logEntry = collapsedLogEntries[uncollapsedLogEntriesIndices[i]]; if (logEntry.logTypeSpriteRepresentation == infoLog && isInfoEnabled) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } else if (logEntry.logTypeSpriteRepresentation == warningLog && isWarningEnabled) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } else if (logEntry.logTypeSpriteRepresentation == errorLog && isErrorEnabled) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } } } } // Update the recycled list view recycledListView.DeselectSelectedLogItem(); recycledListView.OnLogEntriesUpdated(true); ValidateScrollPosition(); }
private bool IsMatch(DebugLogEntry logEntry) { return(string.IsNullOrEmpty(searchInputField.text) || logEntry.logString.IndexOf(searchInputField.text, StringComparison.OrdinalIgnoreCase) > 0); }
// Determine the filtered list of debug entries to show on screen private void FilterLogs() { if (logFilter == DebugLogFilter.None) { // Show no entry indicesOfListEntriesToShow = new List <int>(); } else if (logFilter == DebugLogFilter.All) { if (isCollapseOn) { // All the unique debug entries will be listed just once. // So, list of debug entries to show is the same as the // order these unique debug entries are added to collapsedLogEntries indicesOfListEntriesToShow = new List <int>(collapsedLogEntries.Count); for (int i = 0; i < collapsedLogEntries.Count; i++) { indicesOfListEntriesToShow.Add(i); } } else { // Special (and most common) case: when all log types are enabled // and collapse mode is disabled, list of debug entries to show is // the same as the order all the debug entries are received. // So, don't create a new list of indices indicesOfListEntriesToShow = uncollapsedLogEntriesIndices; } } else { // Show only the debug entries that match the current filter bool isInfoEnabled = (logFilter & DebugLogFilter.Info) == DebugLogFilter.Info; bool isWarningEnabled = (logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning; bool isErrorEnabled = (logFilter & DebugLogFilter.Error) == DebugLogFilter.Error; if (isCollapseOn) { indicesOfListEntriesToShow = new List <int>(collapsedLogEntries.Count); for (int i = 0; i < collapsedLogEntries.Count; i++) { DebugLogEntry logEntry = collapsedLogEntries[i]; if (logEntry.logTypeSpriteRepresentation == infoLog && isInfoEnabled) { indicesOfListEntriesToShow.Add(i); } else if (logEntry.logTypeSpriteRepresentation == warningLog && isWarningEnabled) { indicesOfListEntriesToShow.Add(i); } else if (logEntry.logTypeSpriteRepresentation == errorLog && isErrorEnabled) { indicesOfListEntriesToShow.Add(i); } } } else { indicesOfListEntriesToShow = new List <int>(uncollapsedLogEntriesIndices.Count); for (int i = 0; i < uncollapsedLogEntriesIndices.Count; i++) { DebugLogEntry logEntry = collapsedLogEntries[uncollapsedLogEntriesIndices[i]]; if (logEntry.logTypeSpriteRepresentation == infoLog && isInfoEnabled) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } else if (logEntry.logTypeSpriteRepresentation == warningLog && isWarningEnabled) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } else if (logEntry.logTypeSpriteRepresentation == errorLog && isErrorEnabled) { indicesOfListEntriesToShow.Add(uncollapsedLogEntriesIndices[i]); } } } } // Clear the Selected Log Item Details text clickedLogItemDetails.text = ""; // Update the recycled list view recycledListView.SetEntryIndicesList(indicesOfListEntriesToShow); }
// A debug entry is received void ReceivedLog(string logString, string stackTrace, LogType logType) { DebugLogEntry logEntry = new DebugLogEntry(logString, stackTrace, null); // Check if this entry is a duplicate (i.e. has been received before) int logEntryIndex = collapsedLogEntries.IndexOf(logEntry); bool isEntryInCollapsedEntryList = logEntryIndex != -1; if (!isEntryInCollapsedEntryList) { // It is not a duplicate, // add it to the list of unique debug entries logEntry.logTypeSpriteRepresentation = logSpriteRepresentations[logType]; collapsedLogEntries.Add(logEntry); logEntryIndex = collapsedLogEntries.Count - 1; } else { // It is a duplicate, // increment the original debug item's collapsed count logEntry = collapsedLogEntries[logEntryIndex]; logEntry.count++; } // Add the index of the unique debug entry to the list // that stores the order the debug entries are received uncollapsedLogEntriesIndices.Add(logEntryIndex); // If this debug entry matches the current filters, // add it to the list of debug entries to show if (ShouldAddEntryToFilteredEntries(logEntry.logTypeSpriteRepresentation, isEntryInCollapsedEntryList)) { indicesOfListEntriesToShow.Add(logEntryIndex); } if (logType == LogType.Log) { infoEntryCount++; infoEntryCountText.text = "" + infoEntryCount; // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewInfoLogArrived(); } } else if (logType == LogType.Warning) { warningEntryCount++; warningEntryCountText.text = "" + warningEntryCount; // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewWarningLogArrived(); } } else { errorEntryCount++; errorEntryCountText.text = "" + errorEntryCount; // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewErrorLogArrived(); } } // If log window is visible, update the recycled list view if (isLogWindowVisible) { recycledListView.OnLogEntriesUpdated(); } }
// A debug entry is received private void ReceivedLog(string logString, string stackTrace, LogType logType) { DebugLogEntry logEntry = new DebugLogEntry(logString, stackTrace, null); // Check if this entry is a duplicate (i.e. has been received before) int logEntryIndex; bool isEntryInCollapsedEntryList = collapsedLogEntriesMap.TryGetValue(logEntry, out logEntryIndex); if (!isEntryInCollapsedEntryList) { // It is not a duplicate, // add it to the list of unique debug entries logEntry.logTypeSpriteRepresentation = logSpriteRepresentations[logType]; logEntryIndex = collapsedLogEntries.Count; collapsedLogEntries.Add(logEntry); collapsedLogEntriesMap[logEntry] = logEntryIndex; } else { // It is a duplicate, // increment the original debug item's collapsed count logEntry = collapsedLogEntries[logEntryIndex]; logEntry.count++; } // Add the index of the unique debug entry to the list // that stores the order the debug entries are received uncollapsedLogEntriesIndices.Add(logEntryIndex); // If this debug entry matches the current filters, // add it to the list of debug entries to show Sprite logTypeSpriteRepresentation = logEntry.logTypeSpriteRepresentation; if (isCollapseOn && isEntryInCollapsedEntryList) { if (isLogWindowVisible) { recycledListView.OnCollapsedLogEntryAtIndexUpdated(logEntryIndex); } } else if (logFilter == DebugLogFilter.All || (logTypeSpriteRepresentation == infoLog && ((logFilter & DebugLogFilter.Info) == DebugLogFilter.Info)) || (logTypeSpriteRepresentation == warningLog && ((logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning)) || (logTypeSpriteRepresentation == errorLog && ((logFilter & DebugLogFilter.Error) == DebugLogFilter.Error))) { indicesOfListEntriesToShow.Add(logEntryIndex); if (isLogWindowVisible) { recycledListView.OnLogEntriesUpdated(false); } } if (logType == LogType.Log) { infoEntryCount++; infoEntryCountText.text = infoEntryCount.ToString(); } else if (logType == LogType.Warning) { warningEntryCount++; warningEntryCountText.text = warningEntryCount.ToString(); } else { errorEntryCount++; errorEntryCountText.text = errorEntryCount.ToString(); } }
// Present the log entry in the console private void ProcessLog(QueuedDebugLogEntry queuedLogEntry) { LogType logType = queuedLogEntry.logType; DebugLogEntry logEntry; if (pooledLogEntries.Count > 0) { logEntry = pooledLogEntries[pooledLogEntries.Count - 1]; pooledLogEntries.RemoveAt(pooledLogEntries.Count - 1); } else { logEntry = new DebugLogEntry(); } logEntry.Initialize(queuedLogEntry.logString, queuedLogEntry.stackTrace, null); // Check if this entry is a duplicate (i.e. has been received before) int logEntryIndex; bool isEntryInCollapsedEntryList = collapsedLogEntriesMap.TryGetValue(logEntry, out logEntryIndex); if (!isEntryInCollapsedEntryList) { // It is not a duplicate, // add it to the list of unique debug entries logEntry.logTypeSpriteRepresentation = logSpriteRepresentations[logType]; logEntryIndex = collapsedLogEntries.Count; collapsedLogEntries.Add(logEntry); collapsedLogEntriesMap[logEntry] = logEntryIndex; } else { // It is a duplicate, pool the duplicate log entry and // increment the original debug item's collapsed count pooledLogEntries.Add(logEntry); logEntry = collapsedLogEntries[logEntryIndex]; logEntry.count++; } // Add the index of the unique debug entry to the list // that stores the order the debug entries are received uncollapsedLogEntriesIndices.Add(logEntryIndex); // If this debug entry matches the current filters, // add it to the list of debug entries to show Sprite logTypeSpriteRepresentation = logEntry.logTypeSpriteRepresentation; if (isCollapseOn && isEntryInCollapsedEntryList) { if (isLogWindowVisible) { recycledListView.OnCollapsedLogEntryAtIndexUpdated(logEntryIndex); } } else if (logFilter == DebugLogFilter.All || (logTypeSpriteRepresentation == infoLog && ((logFilter & DebugLogFilter.Info) == DebugLogFilter.Info)) || (logTypeSpriteRepresentation == warningLog && ((logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning)) || (logTypeSpriteRepresentation == errorLog && ((logFilter & DebugLogFilter.Error) == DebugLogFilter.Error))) { indicesOfListEntriesToShow.Add(logEntryIndex); if (isLogWindowVisible) { recycledListView.OnLogEntriesUpdated(false); } } if (logType == LogType.Log) { infoEntryCount++; infoEntryCountText.text = infoEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewInfoLogArrived(); } } else if (logType == LogType.Warning) { warningEntryCount++; warningEntryCountText.text = warningEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewWarningLogArrived(); } } else { errorEntryCount++; errorEntryCountText.text = errorEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewErrorLogArrived(); } } }