Eclipse控制台 - 什么是使堆栈跟踪可点击的规则? [英] Eclipse Console - what are the rules that make stack traces clickable?
问题描述
我记录了很多东西,并注意到Eclipse控制台使Java堆栈跟踪可点击。突出显示异常(转到创建断点对话框),文件名+数字也突出显示(允许直接到该行)。
I log quite a bit of stuff, and have noticed that Eclipse Console makes Java stacktraces clickable. The exception is highlighted (goes to the "Create Breakpoint" dialog box) and the filename + numbers are highlighted too (allows going straight to that line).
如果我可以格式化我的正常日志行,所以Eclipse控制台会做同样的他们。一个可能的方法可能是使它们看起来像堆栈跟踪线,但为了保持尽可能多的信息,我想知道Eclipse用于检测这些行的确切规则,但Eclipse 3.6.2是相当大,所以它是一个艰巨的任务。
I was wondering if I could format my normal log lines so the Eclipse Console would do the same to them. A possible approach could be making them look like stack trace lines, but in order to keep as much information as possible I would like to know the exact rule that Eclipse use to detect these lines, but Eclipse 3.6.2 is rather big so it is a herculean task.
问题是,是什么是在这里玩的规则,定义?
The question is then, what are the rules in play here, and where are they defined?
编辑:logback模式布局片段%msg \ %line\)%n
The logback pattern layout snippet is %msg \(%file:%line\)%n
推荐答案
此片段可能有所帮助。它可以放置在代码中的任何位置,并在eclipse控制台上打印一个可点击的行:
This snippet may help. It can be placed anywhere in your code and will print a "clickable" line on the eclipse console:
StackTraceElement s = Thread.currentThread().getStackTrace()[1];
System.out.printf("%s.%s(%s:%s)%n", s.getClassName(), s.getMethodName(),
s.getFileName(), s.getLineNumber());
更新:
此问题有一个答案,可能包括您的问题的解决方案:
This question has an answer, that may include a solution for your problem:
这里我们来:我们必须通过扩展来提供 org.eclipse.ui.console.IPatternMatchListenerDelegate
的实现 org.eclipse.ui.console.consolePatternMatchListeners
。
Here we go: we have to contribute an implementation of org.eclipse.ui.console.IPatternMatchListenerDelegate
through extension point org.eclipse.ui.console.consolePatternMatchListeners
.
提供例外和行号的超链接堆栈跟踪在 org.eclipse.jdt.debug.ui
插件中定义,实现类在同一个包中。
The contributions that provide hyperlinks for exceptions and line numbers in stack traces are defined in the org.eclipse.jdt.debug.ui
plugin, the implementing classes are in the same bundle.
是正则表达式,可以在贡献插件的 plugin.xml
中找到。
The rules are regular expressions and can be found in the plugin.xml
of the contributing plugin.
这篇关于Eclipse控制台 - 什么是使堆栈跟踪可点击的规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!