gnodet commented on code in PR #14066:
URL: https://github.com/apache/maven/pull/14066#discussion_r4642039909


##########
api/maven-api-log/src/main/java/org/apache/maven/api/logging/LogEventBuilder.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api.logging;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Fluent builder for a single log statement.
+ * <p>
+ * Instances are obtained from {@link Logger#atTrace()}, {@link 
Logger#atDebug()}, etc.
+ * A builder <em>must</em> be consumed in a single chained call; it must not be
+ * stored in a variable across statements, as implementations may reuse
+ * thread-local state for zero-allocation dispatch.
+ * <p>
+ * When the target level is disabled the {@code Logger} returns a shared
+ * {@code NopLogEventBuilder} singleton, making the entire fluent call chain a 
no-op
+ * with zero allocations.
+ *
+ * <pre>{@code
+ * log.atInfo()
+ *    .withKeyValue("module", module.getId())
+ *    .log("Compiling {} source files", count);
+ * }</pre>
+ *
+ * @since 4.0.0
+ */
+@Experimental
+public interface LogEventBuilder {
+
+    /**
+     * Attaches a structured key-value pair to this log event.

Review Comment:
   Structured key-value pairs are for structured log appenders (e.g. 
JSON/ECS/Logstash layouts in Logback or Log4j 2) that capture fields alongside 
the message. For example, `withKeyValue("module", 
id).withKeyValue("duration_ms", elapsed)` produces a JSON log entry with those 
fields indexed separately — useful for log aggregators like 
Elasticsearch/Splunk where you want to filter by field rather than parse the 
message string.
   
   In Maven's context this is the mechanism for attaching build metadata 
(project id, mojo id, duration) as first-class log fields rather than embedding 
them in the message text.
   
   _— Hermès on behalf of @gnodet_



-- 
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]

Reply via email to