public void UpdateEntries() { CheckInit(); int flags = CoreLog.LogEntries.consoleFlags; CoreLog.LogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelLog, true); CoreLog.LogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelWarning, true); CoreLog.LogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelError, true); CoreLog.LogEntries.SetConsoleFlag((int)ConsoleFlags.Collapse, collapse); int count = CoreLog.LogEntries.GetCount(); if (count == m_LastEntryCount) { CoreLog.LogEntries.consoleFlags = flags; CheckRepaint(CheckSearchStringChanged()); return; } if (m_LastEntryCount > count) { ClearEntries(); } CoreLog.LogEntries.SetConsoleFlag((int)ConsoleFlags.ShowTimestamp, true); CoreLog.LogEntries.StartGettingEntries(); for (int i = m_LastEntryCount; i < count; i++) { CoreLog.LogEntry entry = new CoreLog.LogEntry(); if (!CoreLog.LogEntries.GetEntryInternal(i, entry)) { continue; } int mode = 0; string text = null; #if UNITY_2017_1_OR_NEWER CoreLog.LogEntries.GetLinesAndModeFromEntryInternal(i, 10, ref mode, ref text); #else CoreLog.LogEntries.GetFirstTwoLinesEntryTextAndModeInternal(i, ref mode, ref text); #endif int entryCount = 0; if (collapse) { entryCount = CoreLog.LogEntries.GetEntryCount(i); } AddEntry(i, entry, text, entryCount); } CoreLog.LogEntries.EndGettingEntries(); CoreLog.LogEntries.consoleFlags = flags; m_LastEntryCount = count; CheckSearchStringChanged(); CheckRepaint(true); }
private void AddEntry(int row, CoreLog.LogEntry entry, string text, int entryCount) { EntryInfo entryInfo = new EntryInfo { row = row, lines = text, text = GetNumberLines(text), entryCount = entryCount, flags = GetConsoleFlagFromMode(entry.mode), entry = entry }; entryInfo.pure = GetPureLines(entryInfo.text, out entryInfo.tagPosInfos); entryInfo.lower = entryInfo.pure.ToLower(); m_EntryInfos.Add(entryInfo); bool hasSearchString = !string.IsNullOrEmpty(m_SearchString); string searchStringValue = null; int searchStringLen = 0; if (hasSearchString) { searchStringValue = m_SearchString.ToLower(); searchStringLen = searchStringValue.Length; } // 没有将堆栈都进行搜索,以免信息太杂,只根据行数,但是变化行数时不会重新搜索 if (HasFlag((int)entryInfo.flags) && m_CustomFilters.HasFilters(entryInfo.lower) && (!hasSearchString || (entryInfo.searchIndex = entryInfo.lower.IndexOf(searchStringValue, StringComparison.Ordinal)) != -1)) { SearchIndexToTagIndex(entryInfo, searchStringLen); m_FilteredInfos.Add(entryInfo); } if (entryInfo.flags == ConsoleFlags.LogLevelError) { m_TypeCounts[0]++; } else if (entryInfo.flags == ConsoleFlags.LogLevelWarning) { m_TypeCounts[1]++; } else { m_TypeCounts[2]++; } }