cstamas edited a comment on pull request #565:
URL: https://github.com/apache/maven/pull/565#issuecomment-940876114
> Hi, as you ping me there for the replacement of #437 and #438 here is what
I can tell you.
Thanks for reaching out!
> When I created the PRs, I was looking for a standardized way to use &
inject "Logger" (whatever the interface/impl) in different maven places.
Standard plugins used to inherit from Mojo and thus access a Log interface from
Mojo/AbstractMojo but for core extensions (what I was more interested of) it
was not clear what to use and how. Looking at this PR it looks like the answer
is now `inject and use LogFactory`.
Correct. I know it would be simpler to inject logger, but that would
complicate things for Mojos and Components. Now, mojos and components can get
same breed of loggers (even with ctor injection as you point out), as my issue
here was that _while Mojos get loggers injected, components cannot even get to
them even if they want to_.
> Then more specifically for #438 the introduction of the functional
providers of message was more to allow new syntax of writing logs. This PR
provides new Log methods but not functional ones allowing to use lambda or
method references. For me #438 it is still valid or could be merged here with
the other enhancements to Log interface.
Am unsure do we want to invent things here. Am sure that logging API can be
quite "non conventional" even smart, but my choice to be slf4j-like is
intentional, as after all, core and almost everything else around Mojos/plugins
that's the API we use. IMO, it is much simpler for a developer to just follow
one API. After all, as slf4j is lazy, you can still provide some functional
bits that has toString() implementation (so evaluates to String when slf4j asks
for), all you need is a helper:
```
private static Supplier<String> toStringSupplier(final Supplier<String>
stringSupplier) {
return new Supplier<String>() {
@Override
public String get() {
return stringSupplier.get();
}
public String toString() {
return get();
}
};
}
```
and use it as
```
log.info("{}", toStringSupplier(() -> "this is a message"));
```
Isn't this same semantics?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]