简体   繁体   English

显示来自已部署插件的错误

[英]Display error from a deployed plug-in

Finally, after hours of working, I finally got my plug-in to work in the Virtual Eclipse application (the one where you can test your plug-in). 终于,在工作了几个小时之后,我终于使我的插件在Virtual Eclipse应用程序(可以在其中测试您的插件)中使用。 Happy, I created a feature and a site to deploy the plug-in. 高兴,我创建了一个功能和一个站点来部署插件。 After installing, it seems my plug-in isn't working. 安装后,看来我的插件无法正常工作。

Now, I don't know where the errors are or why isn't it working because I was only using System.out.println(error) when I was testing it. 现在,我不知道错误在哪里或为什么不起作用,因为我在测试时仅使用System.out.println(error)

What do I need to use when I want to display the error when a plug-in has been installed in the actual Eclipse application? 在实际的Eclipse应用程序中安装了插件时,如果要显示错误,该怎么办?

Thanks. 谢谢。

You need to write messages to the Eclipse log. 您需要将消息写入Eclipse日志。 This is the .log file in the workspace .metadata directory (both hidden on some platforms). 这是工作区.metadata目录中的.log文件(在某些平台上都隐藏)。

You can write to the log using the ILog interface. 您可以使用ILog界面写入日志。

If you have an Activator class which extends AbstractUIPlugin or Plugin to can get the ILog by calling the getLog() method of Plugin . 如果您有一个扩展了AbstractUIPluginPlugin的Activator类,则可以通过调用PlugingetLog()方法获取ILog

Alternatively you can get the log with: 或者,您可以通过以下方式获取日志:

Bundle bundle = ... your plug-in bundle

ILog log = Platform.getLog(bundle);

Write an entry to the log with something like: 使用类似以下内容的日志条目:

IStatus status = new Status(IStatus.ERROR, "message", exception);

log.log(status);

where exception is any exception you want to report or null . 其中exception是要报告的任何异常,或者为null

You can get the plug-in bundle with: 您可以通过以下方式获取插件包:

Bundle bundle = FrameworkUtil.getBundle(getClass());

or 要么

Bundle bundle = Platform.getBundle("plugin id");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM