Bug 57909

Summary: Add getMessageOutputLevel() method to DefaultLogger.java
Product: Ant Reporter: Daniel Reilly <djreilly>
Component: CoreAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Daniel Reilly 2015-05-08 18:47:35 UTC
I am writing a specialized set of ant tasks.  I have debug code embedded in these tasks.  I would like an integrated solution for logging data from the debug code that derives its logging level from the logger.

I have log() statements set up with the level parameter, but it is not as effecient as checking the level myself before calling log().  I would be able to avoid processing all the calls to other methods that gather the data to put into the log record text.

It appears that a simple extension to the DefaultLogger would do the trick.  I would like a getMessageOutput() that returns current logging level:

    /**
     * Return the current level of message this logger responds to.
     *
     */
    public int getMessageOutputLevel(int level) {
        return this.msgOutputLevel;
    }
Comment 1 Stefan Bodewig 2015-05-08 19:19:51 UTC
*** Bug 57908 has been marked as a duplicate of this bug. ***
Comment 2 Stefan Bodewig 2015-05-14 05:20:39 UTC
I'm not sure how this would help.  In theory there may be multiple BuildListeners attached - each of them using a different log level.  Also, some of our built in BuildListeners and most probably all IDE integrations don't extend DefaultLogger at all.
Comment 3 Daniel Reilly 2015-05-31 17:38:16 UTC
When someone specified the -d (debug) parameter, where is that information stored?  What I need is a simple way to access that information.
Comment 4 Stefan Bodewig 2015-05-31 17:48:59 UTC
(In reply to Daniel Reilly from comment #3)
> When someone specified the -d (debug) parameter, where is that information
> stored?  What I need is a simple way to access that information.

In Main's msgOutputLevel and passed to any BuildLogger's setMessageOutputLevel.

The former is specific to Ant run via the command line, IDE integrations most likely plug in an AntMain implementation of their own.  BuildLogger is an interface, where information is stored is up to the implementation.
Comment 5 Daniel Reilly 2017-09-19 17:11:56 UTC
So, can we add a getMsgOutputLevel() to Main?