gnodet opened a new pull request, #12694:
URL: https://github.com/apache/maven/pull/12694

   ## Summary
   
   Focused, reviewable PR that lays the logging infrastructure foundation for 
the build report work (#12572). Split out from #12572 to enable focused review 
and discussion of the logging architecture.
   
   ### What's included
   
   **Log API enhancements** (`maven-api-core`)
   - `Log.trace()` — 5 overloads + `isTraceEnabled()` to separate Maven core 
internals (trace) from user-facing debug output (debug). Maps to SLF4J TRACE / 
JUL FINEST.
   - `Log.child(name)` — hierarchical sub-loggers for plugins that want to 
separate concerns while keeping level control. Default implementation returns 
`this` for backward compatibility.
   
   **Structured LogEvent** (`maven-api-core`, `maven-core`)
   - `LogEvent` / `LogLevel` API for structured log event representation
   - Optional JUL metadata fields: `sourceClassName()`, `sourceMethodName()`, 
`threadId()` — populated only for events originating from `java.util.logging`, 
`null` for SLF4J/Log API events
   
   **Custom JUL Handler** (`maven-logging`)
   - `MavenJulHandler` replaces `SLF4JBridgeHandler` — reimplements JUL→SLF4J 
bridging while preserving the full `LogRecord` metadata that the standard 
bridge silently drops
   - Uses a ThreadLocal to pass JUL metadata synchronously to 
`ProjectBuildLogAppender` during the same `publish()` call
   - Three code paths, one pipeline: Log API → SLF4J, SLF4J direct, JUL → 
`MavenJulHandler` → SLF4J — all converge on the same structured `LogEvent`
   
   **Structured LogSink** (`maven-logging`, `maven-core`)
   - `MavenSimpleLogger.LogSink` — structured callback with `(level, 
loggerName, cleanMessage, formattedMessage, throwable)` replacing the old 
`Consumer<String>` sink
   - `ProjectBuildLogAppender` produces `LogEvent` objects (with JUL metadata 
when available) instead of raw strings
   - `BuildEventListener.projectLogMessage()` now takes `LogEvent` instead of 
`String`
   
   **Mojo MDC & logger name** (`maven-core`)
   - `maven.mojo.id` MDC key set during mojo execution (format: 
`prefix:goal@executionId`)
   - Logger name changed from `getFullGoalName()` ("compiler:compile") to 
`getImplementation()` (FQCN like 
`org.apache.maven.plugins.compiler.CompilerMojo`) for proper hierarchical SLF4J 
level configuration
   
   **Bug fix**
   - `DefaultLog.warn(Supplier<String>, Throwable)` was calling `logger.info()` 
instead of `logger.warn()`
   
   ### Context
   
   This is Part 1 of the #12572 split. The build report, console modes, and 
warning mode features will follow as separate PRs on top of this foundation. 
See discussion in the [dev@ thread](https://lists.apache.org/thread/...) and 
Martin's feedback on JUL field preservation.
   
   ### Depends on / blocks
   
   - Blocks: #12572 (remaining build report features)
   - Related: #12690 (4.0.x backport of Log API changes)
   - Related: apache/maven-compiler-plugin#1101 (compiler plugin using Log API)
   
   ## Test plan
   
   - [x] `mvn test -pl impl/maven-core,impl/maven-logging` — 580 tests pass
   - [ ] Full CI validation
   - [ ] IT suite with JUL-using plugins (verify metadata preservation)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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