Repository navigation
[#14188] Add lazy arguments to the fluent log event builder - #14215
VirtualSelect wants to merge 1 commit into
Conversation
Keep argument suppliers behind the level check and preserve the original message template and argument order, including during bootstrap. Generated-by: OpenAI Codex
This comment has been minimized.
This comment has been minimized.
gnodet-bot
left a comment
There was a problem hiding this comment.
The addArgument(Object) and addArgument(Supplier<?>) additions look solid — the implementation is clean, the NopLogEventBuilder/BufferingLoggerManager.NOP both short-circuit correctly, and the test coverage for argument ordering, prepend semantics, and disabled-level evaluation is thorough.
One thing that needs to be addressed: the log(String, Supplier<?>) and log(String, Supplier<?>, Supplier<?>) convenience overloads are missing from the LogEventBuilder interface.
We discussed these in #14188. The PR description says they were left aside "as agreed", but looking back at the issue thread, the only agreement was to leave the call-site migration (replacing isDebugEnabled() guards) out of this first slice — not the convenience overloads. Those were explicitly endorsed:
"One note on the
log(format, null)ambiguity you spotted: thelog(String, Supplier<?>)/log(String, Supplier<?>, Supplier<?>)overloads are convenience defaults on the interface. Sincenullis not a validSupplier<?>argument in practice, I'm not too worried about the ambiguity in real code…"
These are default methods on the interface, so they're a trivial addition:
default void log(@Nonnull String format, @Nonnull Supplier<?> arg) {
addArgument(arg).log(format);
}
default void log(@Nonnull String format, @Nonnull Supplier<?> arg1, @Nonnull Supplier<?> arg2) {
addArgument(arg1).addArgument(arg2).log(format);
}They enable the idiomatic single-expression form that was the main motivation for the issue:
logger.atDebug().log("Reading file model from {0}", modelSource::getLocation);Without them, callers have to chain addArgument(...).log(format) manually every time — which works but is more verbose than it needs to be. Please add them before this is merged.
|
Thanks for the review. @gnodet, should the two I checked the overloads with javac: |
Summary
addArgument(Object)andaddArgument(Supplier<?>)toLogEventBuilder. Enabled builders evaluate each supplier at the call site; disabled builders never invoke it.Verification
DefaultLoggerTest,BufferingArgumentTest, andLoggerManagerHolderTest.-Prun-its verifystopped inmaven-implwith five resolver-related test errors. The same five tests fail with the same exception types on the unmodified base. Both logs show the standalone resolver cannot resolve Maven Central in this environment (UnknownHostException). Full integration verification is not claimed.Addresses #14188 (fluent API slice only).
AI assistance: OpenAI Codex.