Esempio n. 1
0
        // 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();
            }
        }
Esempio n. 2
0
        // 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();
                }
            }
        }
Esempio n. 3
0
        // 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();
                }
            }
        }