gnodet-bot commented on code in PR #14062:
URL: https://github.com/apache/maven/pull/14062#discussion_r4611977089


##########
api/maven-api-log/src/main/java/org/apache/maven/api/logging/package-info.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+/**
+ * Maven unified logging API — a first-class, SLF4J-free logging facade for
+ * plugins and extensions.
+ *
+ * <h2>Core types</h2>
+ * <dl>
+ *   <dt>{@link org.apache.maven.api.logging.Logger}</dt>
+ *   <dd>The primary logging interface injected by the container. Supports a 
fluent builder
+ *   API ({@code atInfo()...log(...)}) as well as SLF4J-style convenience 
methods
+ *   ({@code info(...)}, {@code warn(...)}, etc.).</dd>
+ *
+ *   <dt>{@link org.apache.maven.api.logging.LogEventBuilder}</dt>
+ *   <dd>Fluent builder for a single log event, obtained from {@code 
Logger.atLevel()}.
+ *   When the target level is disabled, returns a no-op singleton (zero 
allocations).</dd>

Review Comment:
   ⚠️ **Non-existent method reference**
   
   `Logger.atLevel()` does not exist on the `Logger` interface. The correct 
method is `Logger.at(LogLevel level)`. The shortcut methods are `atTrace()`, 
`atDebug()`, `atInfo()`, `atWarn()`, `atError()`.
   
   ```suggestion
     <dd>Fluent builder for a single log event, obtained from {@code 
Logger.at(LogLevel)}.
   ```



##########
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.
+     *
+     * @param key   the key, never {@code null}
+     * @param value the string value
+     * @return this builder
+     */
+    @Nonnull
+    LogEventBuilder withKeyValue(@Nonnull String key, String value);
+
+    /**
+     * Attaches a structured key-value pair with a {@code long} value.
+     *
+     * @param key   the key, never {@code null}
+     * @param value the numeric value
+     * @return this builder
+     */
+    @Nonnull
+    LogEventBuilder withKeyValue(@Nonnull String key, long value);
+
+    /**
+     * Attaches a structured key-value pair with a {@code boolean} value.
+     *
+     * @param key   the key, never {@code null}
+     * @param value the boolean value
+     * @return this builder
+     */
+    @Nonnull
+    LogEventBuilder withKeyValue(@Nonnull String key, boolean value);
+
+    /**
+     * Attaches a {@link Throwable} to this log event.
+     *
+     * @param t the throwable, may be {@code null} (no-op)
+     * @return this builder
+     */
+    @Nonnull
+    LogEventBuilder withThrowable(Throwable t);
+
+    /**
+     * Overrides the project identifier for this event.
+     * <p>
+     * The default path resolves {@code projectId} from the current thread's
+     * {@code LogContext}; use this method only in the rare cases where the
+     * ThreadLocal context is incorrect (e.g. async hand-offs).
+     *

Review Comment:
   ⚠️ **Javadoc promises behavior the implementation does not deliver**
   
   The Javadoc for `withProjectId()` and `withMojoId()` describes active 
context override semantics and references a `LogContext` ThreadLocal, but both 
`DefaultLogEventBuilder` and `NopLogEventBuilder` implement these as silent 
no-ops (`return this`). There is no `LogContext` implementation in this PR.
   
   Plugins calling `atInfo().withProjectId("my:artifact").log("msg")` will 
silently receive no enrichment. Please update the Javadoc to clarify this is 
reserved for future use, e.g.:
   
   > *Reserved for future structured logging support. The current 
implementation ignores this value; enrichment happens via ThreadLocals set by 
the container.*



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