Eclipse控制台 - 使堆栈跟踪可点击的规则是什么? [英] Eclipse Console - what are the rules that make stack traces clickable?

查看:216
本文介绍了Eclipse控制台 - 使堆栈跟踪可点击的规则是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记录了很多东西,并注意到Eclipse Console使Java堆栈跟踪可点击。突出显示异常(转到创建断点对话框),并且文件名+数字也被突出显示(允许直接到该行)。



我想知道如果我可以格式化我的普通日志行,那么Eclipse控制台会对它们做同样的事情。一种可能的方法可能是使它们看起来像堆栈跟踪线,但是为了保持尽可能多的信息,我想知道Eclipse用来检测这些行的确切规则,但Eclipse 3.6.2是相当大的,所以它是一个可怕的任务。



那么问题是,这里有什么规则,而定义?






编辑:logback模式布局代码段是%msg \(%file: %line\)%n

解决方案

此片段可能有帮助。它可以放置在代码的任何位置,并在eclipse控制台上打印一个可点击行:

  StackTraceElement s = Thread。 。currentThread()的getStackTrace()[1]; 
System.out.printf(%s。%s(%s:%s)%n,s.getClassName(),s.getMethodName(),
s.getFileName(),s .getLineNumber());

更新:



这个问题有一个答案,可能会包含您的问题的解决方案:



Eclipse控制台:检测警告和错误模式并使其可点击






这里我们去:我们必须通过扩展来贡献一个 org.eclipse.ui.console.IPatternMatchListenerDelegate 的实现点 org.eclipse.ui.console.consolePatternMatchListeners



为异常和行号提供超链接的贡献堆栈跟踪在 org.eclipse.jdt.debug.ui 插件中定义,实现类在同一个包中。



规则是正则表达式,可以在贡献插件的 plugin.xml 中找到。


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).

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?


Edit: The logback pattern layout snippet is %msg \(%file:%line\)%n

解决方案

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());

Update:

This question has an answer, that may include a solution for your problem:

Eclipse console: detect warning and error patterns and make them clickable


Here we go: we have to contribute an implementation of org.eclipse.ui.console.IPatternMatchListenerDelegate through extension point org.eclipse.ui.console.consolePatternMatchListeners.

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.

The rules are regular expressions and can be found in the plugin.xml of the contributing plugin.

这篇关于Eclipse控制台 - 使堆栈跟踪可点击的规则是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆