private void ActiveFilter(object data) { ILogContentGetter logContent = data as ILogContentGetter; this.keyword = logContent.HeadMessage; this.Enabled = true; }
public static void GoToLine(ILogContentGetter log, LogEntry logEntry, bool focus) { // Prefer using instanceID as much as possible, more reliable. // Try to reach the object, it might not be a TextAsset. if (logEntry.instanceID != 0) { string path = AssetDatabase.GetAssetPath(logEntry.instanceID); if (string.IsNullOrEmpty(path) == false) { Object sourceFile = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)); if (sourceFile != null) { RowUtility.GoToFileLine(path, logEntry.line, focus); return; } } } // Go to the first reachable frame. for (int j = 0; j < log.Frames.Length; j++) { if (log.Frames[j].fileExist == true) { RowUtility.GoToFileLine(log.Frames[j].fileName, log.Frames[j].line, focus); break; } } }
private void CreateStreamForCategory(int consoleIndex, Row row) { // StreamLog does not receive output from compiler. if ((row.log.mode & (Mode.ScriptCompileError | Mode.ScriptCompileWarning)) != 0) { return; } // Category has a priority over all rules. string category; int hash = row.log.condition.GetHashCode(); if (MainModule.methodsCategories.TryGetValue(hash, out category) == false) { ILogContentGetter log = row as ILogContentGetter; if (log != null) { category = log.Category; } else { category = null; } MainModule.methodsCategories.Add(hash, category); } if (category != null) { for (int j = 0; j < this.streams.Count; j++) { if (this.streams[j].onlyCategory == true && this.streams[j].name == category) { return; } } MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>(); StreamLog stream = new StreamLog(); stream.onlyCategory = true; stream.name = category; stream.Init(this.console, this); foreach (ILogFilter filter in mainSettings.GenerateFilters()) { stream.groupFilters.filters.Add(filter); } this.streams.Add(stream); if (this.StreamAdded != null) { this.StreamAdded(stream); } } }
public ErrorCompileRow(ILogContentGetter logContent) : base(logContent) { this.fileLines = new List <FileLine>(); this.isOpened = true; string raw = logContent.FullMessage; this.hasError = raw.Contains("error"); // Handle message with no file or line as prefix. if (raw.StartsWith("error") || raw.StartsWith("warning") || logContent.Frames.Length == 0) { if (raw.Contains("error CS") == true || raw.Contains("warning CS") == true) { int comma = raw.IndexOf(':'); if (comma == -1) { return; } this.error = raw.Substring(0, comma); this.error = this.error.Substring(this.error.IndexOf(' ') + 1); // Just keep the error number. } } else { int comma = raw.IndexOf(':') + 2; // Totaly empty log is possible! Yes it is! No stacktrace, no file, no line, no log at all! // Bug ref #718608_dh6en6gdivrpuv0q if (comma == 1) { return; } raw = raw.Substring(comma); // Skip ':' and ' ' after "File(Line,Col)" // Separate the error number and the message. comma = raw.IndexOf(':'); if (comma == -1) { return; } this.error = raw.Substring(0, comma); this.error = this.error.Substring(this.error.IndexOf(' ') + 1); // Just keep the error number. } this.lookupError = (this.hasError == true ? "error " : "warning ") + this.error + ":"; }
/// <summary> /// If this stream consumes incoming logs, it checks if the given <paramref name="row"/> is filtered and consumes it. /// </summary> /// <param name="consoleIndex"></param> /// <param name="row"></param> public virtual void ConsumeLog(int consoleIndex, Row row) { // StreamLog does not receive output from compiler. if ((row.log.mode & (Mode.ScriptCompileError | Mode.ScriptCompileWarning)) != 0) { return; } if (this.consumeLog == true) //(this.addConsumedLog == true || // row.isConsumed == false) && { // Category has a priority over all rules. string category; int hash = row.log.fileHash + row.log.line; if (MainModule.methodsCategories.TryGetValue(hash, out category) == false) { ILogContentGetter log = row as ILogContentGetter; if (log != null) { category = log.Category; } else { category = null; } MainModule.methodsCategories.Add(hash, category); } if (this.onlyCategory == true) { if (string.IsNullOrEmpty(category) == false && this.name == category) { row.isConsumed = true; this.consumedLogs.Add(consoleIndex); this.lastIndexConsummed = consoleIndex; } } else if (this.groupFilters.Filter(row) == true) { row.isConsumed = true; this.consumedLogs.Add(consoleIndex); this.lastIndexConsummed = consoleIndex; } } }
/// <summary> /// <para>Adds a new CompileRow or appends the given <paramref name="row"/> to an existing CompileRow.</para> /// <para>From here, we should assume that every logs are compiler outputs, therefore we should not care much about the format and issues when parsing it.</para> /// </summary> /// <param name="row"></param> private void AppendLogToRow(Row row) { try { ILogContentGetter logContent = row as ILogContentGetter; InternalNGDebug.AssertFile(logContent != null, "CompilerLog has received a non-usable Row." + Environment.NewLine + row.log); for (int i = 0; i < this.compileRows.Count; i++) { if (this.compileRows[i].CanAddRow(row) == true) { this.compileRows[i].AppendRow(row); return; } } if (this.sortByError == false) { CompileRow crow = new CompileRow(logContent); crow.Init(this.console, row.log); crow.AppendRow(row); this.compileRows.Add(crow); } else { ErrorCompileRow crow = new ErrorCompileRow(logContent); crow.Init(this.console, row.log); crow.AppendRow(row); this.compileRows.Add(crow); } this.rowsDrawer.Add(this.rowsDrawer.Count); } catch (Exception ex) { InternalNGDebug.LogFileException(ex); } }
public FilterResult CanDisplay(Row row) { if (string.IsNullOrEmpty(this.tag) == true) { return(FilterResult.None); } ILogContentGetter logContent = row as ILogContentGetter; if (logContent == null) { return(FilterResult.None); } GameObject gameObject = EditorUtility.InstanceIDToObject(row.log.instanceID) as GameObject; if (gameObject != null && gameObject.CompareTag(this.tag) == true) { return(FilterResult.Accepted); } return(FilterResult.None); }
string ILogExportSource.GetValue(Row row, int i) { ILogContentGetter logContent = row as ILogContentGetter; return(logContent != null ? logContent.StackTrace : string.Empty); }
public override bool CheckEnd(Row row) { if (string.IsNullOrEmpty(this.keyword) == true) { return(false); } ILogContentGetter logContent = row as ILogContentGetter; if (logContent == null) { return(false); } if (this.useRegex == true || this.wholeWord == true) { RegexOptions options = RegexOptions.Multiline; if (this.caseSensitive == CompareOptions.IgnoreCase) { options |= RegexOptions.IgnoreCase; } string keyword = this.keyword; if (this.wholeWord == true) { keyword = "\\b" + keyword + "\\b"; } try { if (this.searchMode == SearchMode.Content || this.searchMode == SearchMode.Both) { if (Regex.IsMatch(logContent.FullMessage, keyword, options)) { return(true); } } if (this.searchMode == SearchMode.StackTrace || this.searchMode == SearchMode.Both) { if (Regex.IsMatch(logContent.StackTrace, keyword, options)) { return(true); } } } catch (Exception ex) { this.regexSyntaxError = ex.Message; } } else { string[] patterns = this.keyword.Split(' '); if (this.searchMode == SearchMode.Content || this.searchMode == SearchMode.Both) { int i = 0; for (; i < patterns.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(logContent.FullMessage, patterns[i], this.caseSensitive) < 0) { break; } } if (i == patterns.Length) { return(true); } } if (this.searchMode == SearchMode.StackTrace || this.searchMode == SearchMode.Both) { int i = 0; for (; i < patterns.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(logContent.StackTrace, patterns[i], this.caseSensitive) < 0) { break; } } if (i == patterns.Length) { return(true); } } } return(false); }
public override bool CanAddRow(Row row) { ILogContentGetter logContent = row as ILogContentGetter; return(logContent.HeadMessage.Contains(this.lookupError)); }
public virtual void AddLog(int consoleIndex, Row row) { // StreamLog does not receive output from compiler. if ((row.log.mode & (Mode.ScriptCompileError | Mode.ScriptCompileWarning)) != 0) { return; } // Skip if index is older than the last cleared index. if (consoleIndex <= this.lastConsoleIndexDeleted) { return; } // Category has a priority over all rules. string category; int hash = row.log.condition.GetHashCode(); if (MainModule.methodsCategories.TryGetValue(hash, out category) == false) { ILogContentGetter log = row as ILogContentGetter; if (log != null) { category = log.Category; } else { category = null; } MainModule.methodsCategories.Add(hash, category); } //Utility.AssertFile(true, "I=" + i + " " + this.addConsumedLog + " && " + row.isConsumed + " && " + i + " != " + this.lastIndexConsummed); if (this.addConsumedLog == false) { if (row.isConsumed == true && //this.consumedLogs.Contains(i) == false) consoleIndex != this.lastIndexConsummed) { return; } } if (string.IsNullOrEmpty(category) == false || this.onlyCategory == true) { if (this.name == category) { //Utility.AssertFile(true, "added " + i); // Count row, but do not display if it is not options compliant. this.CountLog(row); if (this.CanDisplay(row) == true) { this.rowsDrawer.Add(consoleIndex); this.OnRowAdded(this, row, consoleIndex); if (this.pauseOnLog == true && EditorApplication.isPlaying == true) { EditorApplication.isPaused = true; } } } return; } // Exclude filtered row. if (this.groupFilters.Filter(row) == true) { //Utility.AssertFile(true, "added " + i); // Count row, but do not display if it is not options compliant. this.CountLog(row); if (this.CanDisplay(row) == true) { this.rowsDrawer.Add(consoleIndex); this.OnRowAdded(this, row, consoleIndex); if (this.pauseOnLog == true && EditorApplication.isPlaying == true) { EditorApplication.isPaused = true; } } } }
public FilterResult CanDisplay(Row row) { if (string.IsNullOrEmpty(this.keyword) == true) { return(FilterResult.None); } ILogContentGetter logContent = row as ILogContentGetter; if (logContent == null) { return(FilterResult.None); } FilterResult cachedResult; if (this.cachedResults.TryGetValue(row.log.condition, out cachedResult) == true) { return(cachedResult); } if (this.useRegex == true || this.wholeWord == true) { RegexOptions options = RegexOptions.Multiline; if (this.caseSensitive == CompareOptions.IgnoreCase) { options |= RegexOptions.IgnoreCase; } string keyword = this.keyword; if (this.wholeWord == true) { keyword = "\\b" + keyword + "\\b"; } try { if (this.searchMode == SearchMode.Content || this.searchMode == SearchMode.Both) { if (Regex.IsMatch(logContent.FullMessage, keyword, options)) { this.cachedResults.Add(row.log.condition, FilterResult.Accepted); return(FilterResult.Accepted); } } if (this.searchMode == SearchMode.StackTrace || this.searchMode == SearchMode.Both) { if (Regex.IsMatch(logContent.StackTrace, keyword, options)) { this.cachedResults.Add(row.log.condition, FilterResult.Accepted); return(FilterResult.Accepted); } } } catch (Exception ex) { this.regexSyntaxError = ex.Message; } } else { if (this.searchPatterns == null) { this.searchPatterns = Utility.SplitKeywords(this.keyword, ' '); } if (this.searchMode == SearchMode.Content || this.searchMode == SearchMode.Both) { int i = 0; if (this.caseSensitive == CompareOptions.None) { for (; i < this.searchPatterns.Length; i++) { if (logContent.FullMessage.FastContains(this.searchPatterns[i]) == false) { break; } } if (i == this.searchPatterns.Length) { this.cachedResults.Add(row.log.condition, FilterResult.Accepted); return(FilterResult.Accepted); } } else { for (; i < this.searchPatterns.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(logContent.FullMessage, this.searchPatterns[i], this.caseSensitive) < 0) { break; } } if (i == this.searchPatterns.Length) { this.cachedResults.Add(row.log.condition, FilterResult.Accepted); return(FilterResult.Accepted); } } } if (this.searchMode == SearchMode.StackTrace || this.searchMode == SearchMode.Both) { int i = 0; if (this.caseSensitive == CompareOptions.None) { for (; i < this.searchPatterns.Length; i++) { if (logContent.StackTrace.FastContains(this.searchPatterns[i]) == false) { break; } } if (i == this.searchPatterns.Length) { this.cachedResults.Add(row.log.condition, FilterResult.Accepted); return(FilterResult.Accepted); } } else { for (; i < this.searchPatterns.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(logContent.StackTrace, this.searchPatterns[i], this.caseSensitive) < 0) { break; } } } if (i == this.searchPatterns.Length) { this.cachedResults.Add(row.log.condition, FilterResult.Accepted); return(FilterResult.Accepted); } } } this.cachedResults.Add(row.log.condition, FilterResult.Refused); return(FilterResult.Refused); }
public static Rect DrawStackTrace(ILogContentGetter log, RowsDrawer rowsDrawer, Rect r, int i, Row row) { StackTraceSettings settings = HQ.Settings.Get <StackTraceSettings>(); float width = r.width; // Substract viewRect to avoid scrollbar. r.height = settings.height; // Display the stack trace. int j = 0; foreach (var frame in log.Frames) { // Hide invisible frames. if (r.y - rowsDrawer.currentVars.scrollbar.Offset > rowsDrawer.bodyRect.height) { break; } r.x = 0F; r.width = width - 16F; GUI.SetNextControlName("SF" + i + j); if (GUI.Button(r, frame.frameString, settings.Style) == true) { if (RowUtility.CheckLowestRowGoToLineAllowed(j) == true) { GUI.FocusControl("SF" + i + j); r.y -= rowsDrawer.currentVars.scrollbar.Offset; RowUtility.GoToLine(r, frame); r.y += rowsDrawer.currentVars.scrollbar.Offset; } } // Handle hover overflow. if (r.y - rowsDrawer.currentVars.scrollbar.Offset + r.height > rowsDrawer.bodyRect.height) { r.height = rowsDrawer.bodyRect.height - r.y + rowsDrawer.currentVars.scrollbar.Offset; } if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == true) { r.y -= rowsDrawer.currentVars.scrollbar.Offset; RowUtility.PreviewStackFrame(rowsDrawer, r, frame); r.y += rowsDrawer.currentVars.scrollbar.Offset; } r.x = r.width; r.width = 16F; if (GUI.Button(r, "+", settings.Style) == true) { StackTraceSettings stackTrace = HQ.Settings.Get <StackTraceSettings>(); GenericMenu menu = new GenericMenu(); if (frame.raw == null) { InternalNGDebug.LogError("The frame stack is invalid." + Environment.NewLine + frame); } menu.AddItem(new GUIContent("Set as Category"), false, RowUtility.SetAsCategory, frame.raw); string f = RowUtility.GetFilterNamespace(frame.raw); if (f != null) { if (stackTrace.filters.Contains(f) == false) { menu.AddItem(new GUIContent("Skip Namespace \"" + f + "\""), false, RowUtility.AddFilter, f); } else { menu.AddDisabledItem(new GUIContent("Skip Namespace \"" + f + "\"")); } } f = RowUtility.GetFilterClass(frame.raw); if (f != null) { if (stackTrace.filters.Contains(f) == false) { menu.AddItem(new GUIContent("Skip Class \"" + f + "\""), false, RowUtility.AddFilter, f); } else { menu.AddDisabledItem(new GUIContent("Skip Class \"" + f + "\"")); } } f = RowUtility.GetFilterMethod(frame.raw); if (f != null) { if (stackTrace.filters.Contains(f) == false) { menu.AddItem(new GUIContent("Skip Method \"" + f + "\""), false, RowUtility.AddFilter, f); } else { menu.AddDisabledItem(new GUIContent("Skip Method \"" + f + "\"")); } } menu.AddItem(new GUIContent("Manage filters"), false, RowUtility.GoToSettings); menu.ShowAsContext(); } ++j; r.y += r.height; } return(r); }
public CompileRow(ILogContentGetter logContent) { this.isOpened = true; this.file = logContent.Frames[0].fileName; this.errorLines = new List <ErrorLine>(); }
public virtual bool CanAddRow(Row row) { ILogContentGetter logContent = row as ILogContentGetter; return(this.file == logContent.Frames[0].fileName); }