在 Eclipse 插件中记录调试和跟踪消息的最佳实践是什么?
What is the best practice for logging debug and trace messages in Eclipse plugin?
Eclipse IStatus interface has message statuses different from ones usually used in Java. Furthermore the Status class 构造函数允许提供插件特定代码,但没有说明如何使用它。
从 Eclipse 插件打印调试和跟踪消息的推荐方法是什么?
编辑:我对记录跟踪和调试消息特别感兴趣,因为 IStatus 只允许 OK、INFO、WARNING、ERROR 和 CANCEL。
也不清楚什么时候应该使用OK和CANCEL。
ILog
界面在主 Eclipse 日志(工作区 .metadata 目录中的 .log 文件)中记录 IStatus
个对象。
如果您的插件有一个从 Plugin
(或 AbstractUIPlugin
)派生的激活器,您可以使用 getLog()
方法为您的插件获取 ILog
接口 Plugin
.
您也可以使用
Bundle bundle = Platform.getBundle("plugin id");
ILog log = Platform.getLog(bundle);
IStatus
在多种情况下使用。 OK
和 CANCEL
状态代码在 IStatus
用于指示操作结果时使用,它们并不真正用于记录。
注意:ILog
界面总是记录它给定的所有内容,无法启用或禁用不同级别的日志记录。
Eclipse IStatus interface has message statuses different from ones usually used in Java. Furthermore the Status class 构造函数允许提供插件特定代码,但没有说明如何使用它。
从 Eclipse 插件打印调试和跟踪消息的推荐方法是什么?
编辑:我对记录跟踪和调试消息特别感兴趣,因为 IStatus 只允许 OK、INFO、WARNING、ERROR 和 CANCEL。 也不清楚什么时候应该使用OK和CANCEL。
ILog
界面在主 Eclipse 日志(工作区 .metadata 目录中的 .log 文件)中记录 IStatus
个对象。
如果您的插件有一个从 Plugin
(或 AbstractUIPlugin
)派生的激活器,您可以使用 getLog()
方法为您的插件获取 ILog
接口 Plugin
.
您也可以使用
Bundle bundle = Platform.getBundle("plugin id");
ILog log = Platform.getLog(bundle);
IStatus
在多种情况下使用。 OK
和 CANCEL
状态代码在 IStatus
用于指示操作结果时使用,它们并不真正用于记录。
注意:ILog
界面总是记录它给定的所有内容,无法启用或禁用不同级别的日志记录。