Le 2024-03-03 à 20 h 38, Romain Manni-Bucau a écrit :
the idea of maven-api was to abstract anything from the implementation
to be able to change
A standard Java interface is as good as a Maven interface for that
purpose if they define equivalent methods, which is the case of
System.Logger versus Maven Log.
if you use System.Logger you can't until you don't respect the
contract which implies LoggerFinder is used which would be a
misbehavior of the JVM for any user - and as overriding JUL it is used.
I'm not aware of any contract saying that System.Logger must be obtained
by System.getLogger(). The Javadoc only said "are typically obtained
from the System class". Users are not supposed to expect a particular
implementation. If the logger is provided by IOC (as it is in Maven),
users are not supposed to expect that the instance was fetched in any
particular way.
So you mean reusing existing impl? this would be handled by maven
bridge so not an issue to me, same as today there.
As said above, the purpose of an interface is to allow implementation to
change. I provided an example where switching to the standard
implementation would be useful for debugging purposes. The standards
implementations need to be invoked directly (not through a custom Log
interface) for providing useful "source class" and "source method"
information. That is the issue. I'm not sure what a "Maven bridge" is,
but if it is some kind of wrappers, this is an extra complexity which
need to be justified by extra features. In the current Maven Log
interface, there is no such extra features except slightly more compact
method calls (logging levels as method names instead of a method parameter).
I'm not sure what you plan to do but it is the same amount of work
(normalized by the capacity of the API, indeed JUL has more API than
current System.Logger).
I have no plan yet, only making a proposal based on what I saw in the
Maven compiler plugin. I agree that java.util.logging has more
capabilities and I would generally be in favour of switching to it (this
is what I use myself in my projects). However, in the particular case of
Maven, the situation is a little bit different because Maven uses the
Log interface sometime for logging, and sometime for console output. For
example, the Maven compiler plugin produces some messages saying "Using
XYZ" (this is logging), then a block of text representing the Mojo
execution result (success or failure) for the person who launched Maven
(this is console output). So in the way that it is used by Maven, Log is
not really a logger interface but rather a "println" facade which can
also, in some occasions, be a real logger.
The proposal to use System.Logger is just that: continue to use it as a
"println" facade as Maven currently does, but with the added capability
to switch to a useful logger when needed (e.g. for debugging).
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]