[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: Handling exceptions in UI plug-ins

"Mazen Faraj" <mazenfaraj@xxxxxxxx> wrote in message
news:9bhqck$aik$1@xxxxxxxxxxxxxxxx
> Jeff,
> just a quick question here.
> Does the ILog instance that is returned by Plugin.getLog() know about the
> "isDebugging" flag of it's
> associated plugin?

No.  the log is not just a debugging tool.  It is available for use anytime
your plugin detects a situation that it wants to report/record.  Certainly
in debug scenarios you may want to write more information.

> The reason I ask is because I first thought that simply setting the
> debugging flag of a plugin to false will prevent a log from forwarding the
> events to the registered listeners, but this is not the case
> (please correct me if I'm wrong).
> So I guess it should be my listener implementation that checks that
> pluging's isDebugging state to see
> whether or not we have to log.

You have a couple options.  Test isDebugging() in the code that writes to
the ILog or, as you suggest, implement a listener which ignores messages
when not in debug mode.  I would tend to do the former as it would perform
better: If you are not debugging you don't even bother to create the Status
and write it to the log.

> Another issue is, can I prevent the default platform listener from logging
> events from my plugin?
> In general, would this be a bad thing to do?
> We have our own log listener that does the job, and we don't want to log
to
> two files
> (one will be in our plugin's state area, and the other would be the
default
> .log file in the workbench's metadata directory).

Right.  As you note, the current implementation of the platform (i.e.,
runtime plugin) log listener is to catch everything and write it to a .log
file in the .metadata area.  Filtering would be interesting but is not
currently supported.  The problem starts to get pretty complicated.  There
is a whole JSR (47 I think) on this topic.  For now rather than "we don't
want to log to two files" look at it as "we (i.e., you) are logging it to
our file.  The platform may or may not log it as well".

Jeff