gnodet-bot commented on code in PR #2157:
URL: https://github.com/apache/maven-resolver/pull/2157#discussion_r4082043518


##########
maven-resolver-named-locks-ipc/src/main/java/org/eclipse/aether/named/ipc/IpcServer.java:
##########
@@ -213,17 +218,29 @@ static IpcServer runServer(SocketFamily family, String 
tmpAddress, String rand)
 
     private static void debug(String msg, Object... args) {
         if (DEBUG) {
-            System.out.printf("[ipc] [debug] " + msg + "\n", args);
+            if (forkedProcess) {
+                System.out.printf("[ipc] [debug] " + msg + "\n", args);
+            } else {
+                LoggerFactory.getLogger(IpcServer.class).debug(msg, args);
+            }
         }
     }
 
     private static void info(String msg, Object... args) {
-        System.out.printf("[ipc] [info] " + msg + "\n", args);
+        if (forkedProcess) {
+            System.out.printf("[ipc] [info] " + msg + "\n", args);
+        } else {
+            LoggerFactory.getLogger(IpcServer.class).info(msg, args);

Review Comment:
   ⚠️ **Printf-style format strings are not compatible with SLF4J's `{}` 
placeholder syntax.**
   
   The `msg` strings passed to the helper methods use `printf` format 
specifiers (`%s`, `%d`). For example:
   
   ```java
   info("IpcServer started at %s", getLocalAddress().toString());
   info("New client connected (%d connected)", c);
   info("%d clients remained", c);
   debug("Created context %s", context.id);
   debug("Locking in context %s", context.id);
   ```
   
   When these hit the `!forkedProcess` branch, SLF4J receives `"IpcServer 
started at %s"` with argument `[address]`. SLF4J only substitutes `{}` — it 
passes `%s` through literally. The result in the log is `"IpcServer started at 
%s"` with the address silently discarded. This affects all three new SLF4J call 
sites (`debug`, `info`, `error`).
   
   All call-site format strings must be converted to SLF4J `{}` syntax at the 
same time as this change. Either update the call sites, or convert the helper 
methods to do the translation:
   
   ```suggestion
               
LoggerFactory.getLogger(IpcServer.class).info(msg.replaceAll("%[sd]", "{}"), 
args);
   ```
   
   Or, cleaner — convert all format strings at the call sites (e.g. `"IpcServer 
started at {}"`, `"New client connected ({} connected)"`) and drop the 
printf-style approach entirely.



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