Bug 22460 - No access to the message output level from API
Summary: No access to the message output level from API
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.5.4
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
: 23688 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-15 13:34 UTC by Sergey Petrov
Modified: 2008-11-24 03:57 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Petrov 2003-08-15 13:34:51 UTC
Here is my situation : I'd like to control the amount of the info that my 
custom task puts on the screen according to verbosity settings that user passes 
in the commanline (-verbose, -debug etc.). The task itself is a wrapper around 
the existing code that uses System.out/System.err and I can manipulate the 
level of its' output with a set of proprietary parameters. But I can not match 
them with Ant's message level since I have no access to it at runtime. It would 
be nice to have something like Project.getMessageOutputLevel() that returns the 
current message level set from the command line.
Of course my other alternative is to provide something like 'verbose' attribute 
on my task but this is ugly since I have to explicitly set this flag every time 
rather than automatically inheriting user settings.
Comment 1 Steve Loughran 2003-08-15 17:39:53 UTC
Here is the problem. The output level choice in ant is a final decision made by
the output listeners and loggers, not something that is actually known by the
logging components you call at logging time. This is different from log4j and
siblings where you can go log.isDebug(). That said, I think the project does
know what its invocation parameters are and there is no reason why the command
line choice cannot be stored somewhere.

One thing I have been debating doing, so as to control the amount of info
generated by some Axis tasks that log via commons-logging, is to write a commons
logging compatible logger that routes all log info to the ant logger. I will try
working on this again; it may need some tweaks to the commons logger itself. If
we add this, and your code moves to the commons logger API (a good practise,
IMO), then you could leverage this functionality.
Comment 2 Dominique Devienne 2003-08-15 19:15:28 UTC
I've been considering doing the same thing for JDK 1.4 logging, as my tasks 
often are just wrapper to Ant-independent classes that use java.util.logging.

How about I wait on you to provide a nice abstract base class that does most of 
the work ;-) Cheers, --DD
Comment 3 Stefan Bodewig 2005-03-17 16:26:11 UTC
*** Bug 23688 has been marked as a duplicate of this bug. ***