What if I said that I was only interested in knowing if the ant command line "-verbose" switch was enabled or not (as opposed to knowing anything about what log listeners are doing)?


Steve.

Conor MacNeill wrote:


Stephen McConnell wrote:


Is there a way I can test if an ant project is running in verbose mode or not? Nothing jumped out at me when going over the javadocs. I'm hoping there's something I can access via the Project class.



No, not really. Verbosity setting is not a property of the Project but up to the individual build listeners. IOW, the Project broadcasts all events and the build listeners decide what they are going to do with that. If you want to control based on log level, you'd have to determine the interest level of all of the build listeners. There is no interface to do that today.


The separation is pretty clean but it does mean that expensive logging operations are not to be undertaken lightly.

In Ant, one of the build listeners is special. It is *the* logger. It implements the BuildLogger interface and is the one which is controlled by the command line -v and -debug switches. Other build listeners are controlled by mechanisms specific to each listener.

Now, for a while I've been thinking about whether there should be a mechanism to control that logger. It would allow tasks to change the logger's level dynamically. This is actually possible now but a new interface, BuildLogger2, could allow you to query the debug level of the logger. Note that if this were possible, then deciding not to issue log messages based on the state of *one* listener would affect all other listeners. That may not be cool, but would be at the task writer's discretion.

Conor

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--

|---------------------------------------|
| Magic by Merlin                       |
| Production by Avalon                  |
|                                       |
| http://avalon.apache.org              |
|---------------------------------------|

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to