Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Grab Eclipse Console Output Painlessly

DZone's Guide to

How to Grab Eclipse Console Output Painlessly

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

In your plugin, if you want to do something with each line of your eclipse output console, for example write that line to a file, or parsing it before sending it to your custom eclipse view, you should create a class which implements IConsoleLineTracker, and you should add this extension point to your plugin.xml.

[img_assist|nid=1032|title=|desc=The steps are explained well here...|link=none|align=none|width=256|height=192]

Now, suppose your class implementing IConsoleLineTracker is this:

public class LogTracker implements IConsoleLineTracker {

private IConsole m_console;

public void dispose() {

}

public void init(IConsole console) {
m_console = console;
}

public void lineAppended(IRegion region) {
try {
String line = m_console.getDocument().get(region.getOffset(), region.getLength());

// DO SOMETHING WITH THAT LINE
} catch (BadLocationException e) {
WrCheck.logError(e);
}
}
}

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. 

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}