merlimat opened a new pull request, #4754:
URL: https://github.com/apache/bookkeeper/pull/4754

   First phase of the slog migration 
[BP-69](https://github.com/apache/bookkeeper/pull/4751).
   Tracking issue: #4750.
   
   This PR adds the `slog` dependency and `@CustomLog` wiring, and converts the 
`bookkeeper-common` module. Subsequent PRs will convert the rest of the 
codebase module by module (`stats` + `allocator`, `bookkeeper-server`, 
`bookkeeper-http` + `tools`, `stream/distributedlog`, peripheral modules, and a 
final cleanup).
   
   ## Summary
   
   - Add `io.github.merlimat.slog:slog:0.9.7` to `pom.xml` (alongside the 
existing SLF4J API — SLF4J stays on the classpath as the rendering backend; no 
log-config change required to upgrade).
   - Add `lombok.config` at the repo root so `@CustomLog` generates a slog 
`Logger` instead of an SLF4J one:
     ```
     lombok.log.custom.declaration = io.github.merlimat.slog.Logger \
         io.github.merlimat.slog.Logger.get(TYPE)
     ```
   - Convert 6 files in `bookkeeper-common`:
     - `AbstractLifecycleComponent`, `AutoCloseableLifecycleComponent`
     - `LogExceptionRunnable`, `OrderedExecutor`, `SafeRunnable`
     - `TestOrderedExecutorDecorators` (test class)
   
   ## Conventions (to be applied throughout the migration)
   
   - `@Slf4j` → `@CustomLog`; `LoggerFactory.getLogger(X.class)` → 
`Logger.get(X.class)`; naming: static = `LOG`, instance-bound = `log`.
   - `log.info("text {} {}", a, b)` becomes `log.info().attr("a", a).attr("b", 
b).log("text")` — SLF4J `{}` params turn into named structured attrs, not 
printf-style format specifiers.
   - Classes with identity (ledgerId, bookieId, …) will (in later PRs) build 
instance-bound loggers in the constructor so every event carries the identity 
attributes without repeating them at each call site.
   - `if (log.isDebugEnabled())` guards are removed; slog returns a no-op 
`Event` when the level is disabled.
   - Expensive attr values use slog's lambda form (`log.debug(e -> ...)` or 
`.attr(k, () -> expensive)`) so the work is only performed when the level is 
actually enabled.
   
   ## Not included in this PR
   
   - No module outside `bookkeeper-common` is converted.
   - No wire-protocol, binary-format, metadata-format, metric, or CLI change.
   - Client API changes (`withLoggerContext(Map<String, Object>)` on 
`CreateBuilder`/`OpenBuilder`/`DeleteBuilder`) are deferred to a later PR in 
the BP-69 series.
   
   ## Test plan
   
   - [x] `mvn -pl bookkeeper-common -am compile -DskipTests` passes
   - [ ] Existing `bookkeeper-common` unit tests still pass
   - [ ] Rendered log output on a local run unchanged (slog's SLF4J handler 
forwards structured attrs as MDC, so existing Logback/Log4j2 configs keep 
working)


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