[ 
https://issues.apache.org/jira/browse/UIMA-994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743252#action_12743252
 ] 

Marshall Schor commented on UIMA-994:
-------------------------------------

Re: imperfect mapping, I can see your point.

Here's one other issue: the exiting Logger interface for this doesn't have a 
getLevel() method.  If we add this to the interface, it will break existing 
code.  So, we could add it to the each of the 3 classes that UIMA has that 
implement the Logger interface, but then the user would be faced with

a) determining which impl is being used,
b) "casting" to that, and then
c) calling the getLevel() method.

or, if we added a new interface, say org.apache.uima.Logger_v2 extends 
org.apache.uima.Logger which adds the getLevel() method, and changed the 3 
provided logger impls to implement this interface, then users would have to see 
if the logger was an instance of Logger_v2, and if so, cast to that and call 
the getLevel().

Is there a better way?  Is this complexity worth introducing and documenting?

> Add Logger.getLevel()
> ---------------------
>
>                 Key: UIMA-994
>                 URL: https://issues.apache.org/jira/browse/UIMA-994
>             Project: UIMA
>          Issue Type: New Feature
>            Reporter: Steven Bethard
>
> org.apache.uima.util.Logger should expose a .getLevel() method to match the 
> existing .setLevel() method. This is needed, for example, by unit tests that 
> test exceptions and want to temporarily suppress logging messages. In such 
> situations, you want to get the original logging level, set the level to 
> Level.OFF, and then later restore the original logging level. Currently, to 
> get the original logging level, you have to write code like:
>     if (UIMAFramework.getLogger().isLoggable(Level.ALL)) {
>        return Level.ALL;
>     } else if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
>        return Level.FINEST;
>     } ...
> Nasty! Adding .getLevel() shouldn't be too difficult -- both 
> org.apache.log4j.Logger and java.util.logging.Logger already have .getLevel() 
> methods, so these just need appropriately wrapped.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to