Reputation: 1023
I'm working on an Eclipse RCP plugin. One of the commands in the plugin does some data validation, and logs messages to the Eclipse Error Log view.
I'd like the command to clear the Error Log before it starts its work, so that when the command finishes, the Error Log only contains errors relevant to the command's most recent invocation.
I've found that I can delete the log file itself by doing this:
Platform.getLogFileLocation().toFile().delete();
However, as you might expect, the Error Log doesn't refresh its contents just because I snuck behind its back and deleted that file.
I poked around in org.eclipse.ui.internal.views.log.LogView
, and while I do see places where the view updates itself, I don't see a straightforward way to trigger a "clear & refresh."
Is there a way to ask the Error Log to double-check its backing file and refresh itself? Or, is there a more "reasonable" way to get the view cleared?
Update: one slightly-kludgy way to get the log to update itself is to log something else.
I'm currently logging an "info" message right after I delete the old log file, which isn't ideal, but it's got me close enough to where I want to be, for now:
Platform.getLogFileLocation().toFile().delete();
Plugin plugin = Plugin.getPlugin();
ILog log = plugin.getLog();
log.log(new Status(IStatus.INFO, Plugin.PLUGIN_ID, "Starting utility validation pass..."));
Upvotes: 0
Views: 3006
Reputation: 3838
First, you said you are creating an RCP product. The log view is from the PDE plugin, so unless you intentionally specify it in the RCP, it will never be available for your users. Note that your development launch configuration may include it as part of the launch, but it might not be in your actual RCP.
For your question - I can't see any easy way of doing it without a serious hack to the private/protected members of the LovView class. If you intend to include a LogView in your RCP, you may consider extending the LogView, and expose a method to delete the log (or call the 'protected' reloadLog() right after you delete the log file).
Hope that helps
Upvotes: 1