Thanks, Dominique. You stated this quite clearly.

It seems that, since the project knows all its listeners to notify them of
an event, it wouldn't be so hard to add a method to query all the listeners
for their log level and then return the max of that. The build listeners
would also need a getter for their log level. I will allow that, by this
time, you're having to do a certain amount of work to spare yourself some
other work. And I'll also allow that the work you're being spared is
typically a negligible burden.

There's one other matter I want to investigate when it comes to logging. I
may want my Ant task to consume some component that wasn't written for Ant,
so it doesn't have a handle on the Project or a ProjectComponent to log
anything. Perhaps it uses log4j. I'd like to see to what extent Ant's
logging can coordinate with and control the Ant-agnostic logging.

Not a question so much as thinking out loud.

On Mon, Jan 18, 2010 at 2:05 PM, Dominique Devienne <ddevie...@gmail.com>wrote:

> On Sun, Jan 17, 2010 at 11:30 PM, Mitch Gitman <mgit...@gmail.com> wrote:
> > Is there any programmatic mechanism within Ant to arbitrarily query what
> the
> > current log level is? [...]
> >
> > What I'd like to do is invoke getProject().log("Some message",
> > Project.MSG_VERBOSE) only if the current log level is verbose.
>
> No indeed. The reason being that Ant doesn't keep track of the
> "highest" log level for the Logger or the Listeners, because these
> guys don't declare whether the "max" level they are interested in. the
> -verbose or -debug you pass in the CLI is used by the one Logger, but
> there can be other Listener instances that want to get debug messages
> even though the Logger does not care about those. There is therefore
> no way to avoid generating those strings and sending out these logging
> events, despite potentially no one wanting them. Would be a valuable
> addition IMHO, but since for BC reasons you'd have to "default" the
> max_log_level arg added to Project.addListener(), code that doesn't
> use the new API would push the project's max log level to the debug
> anway. See what I mean? I'm not sure what I wrote is very clear I'm
> afraid. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
> For additional commands, e-mail: user-h...@ant.apache.org
>
>

Reply via email to