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


##########
impl/maven-core/src/main/java/org/apache/maven/internal/build/DefaultLogEvent.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.internal.build;
+
+import java.time.Instant;
+
+import org.apache.maven.api.build.report.LogEvent;
+import org.apache.maven.api.build.report.LogLevel;
+
+/**
+ * Immutable implementation of {@link LogEvent}.
+ * <p>
+ * Public to allow construction from other packages within the Maven
+ * implementation (e.g. {@code ProjectBuildLogAppender}).
+ *
+ * @param timestamp        when the event was produced
+ * @param level            the severity level
+ * @param message          the clean log message (without level prefix or ANSI)
+ * @param loggerName       the name of the logger, or {@code null}
+ * @param stackTrace       the stack trace string, or {@code null}
+ * @param formattedMessage the fully formatted console line, or {@code null}
+ * @param sourceClassName  the source class name (Log API mojo FQCN or JUL 
source), or {@code null}
+ * @param sourceMethodName the source method name (via StackWalker or JUL), or 
{@code null}
+ * @param threadId         the originating thread ID, or {@code -1} if 
unavailable
+ * @param sequenceNumber   the global sequence number for ordering, or {@code 
-1} if unavailable
+ * @param projectId        the project this event belongs to, or {@code null}
+ * @param mojoId           the mojo execution that produced this event, or 
{@code null}
+ */
+public record DefaultLogEvent(

Review Comment:
   You're right that thread name is very useful for consumers — log analysis 
tools and build reporters want to show it, and reconstructing it after the fact 
from a thread ID is fragile (the thread might be gone, pooled thread names 
rotate, etc.).
   
   The reason I didn't include it: `DefaultLogEvent` is a record and `threadId` 
was already there. Adding `threadName` is straightforward — it's just 
`Thread.currentThread().getName()` at capture time in `ProjectBuildLogAppender` 
and `MavenJulHandler` (`LogRecord.getThreadID()` doesn't give us the name, but 
we can call `Thread.currentThread().getName()` at the same point we capture the 
ID).
   
   I'll add `threadName()` as a default-null method on the interface and 
populate it in both capture paths. The only case where it won't be available is 
events constructed directly in tests or outside the pipeline — same as 
`threadId()`.



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