From 1243e452a7e4a0728155d3ff981f3353ee680748 Mon Sep 17 00:00:00 2001 From: Travis Lyons Date: Fri, 7 Aug 2026 20:53:48 +0000 Subject: [PATCH] Replace System.out usage with SLF4J logging Addresses SonarQube java:S106 by adding an SLF4J logger to each affected class and routing all standard-output writes through it. --- build.gradle | 5 +++++ .../example/primitive/wrappers/LaunchChecklistApp.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 224d290..330e170 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,11 @@ repositories { mavenCentral() } +dependencies { + implementation 'org.slf4j:slf4j-api:2.0.16' + runtimeOnly 'org.slf4j:slf4j-simple:2.0.16' +} + application { mainClass = 'dev.trly.java.example.primitive.wrappers.LaunchChecklistApp' } diff --git a/src/main/java/dev/trly/java/example/primitive/wrappers/LaunchChecklistApp.java b/src/main/java/dev/trly/java/example/primitive/wrappers/LaunchChecklistApp.java index e0e3158..fd1c887 100644 --- a/src/main/java/dev/trly/java/example/primitive/wrappers/LaunchChecklistApp.java +++ b/src/main/java/dev/trly/java/example/primitive/wrappers/LaunchChecklistApp.java @@ -1,6 +1,11 @@ package dev.trly.java.example.primitive.wrappers; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public final class LaunchChecklistApp { + private static final Logger LOGGER = LoggerFactory.getLogger(LaunchChecklistApp.class); + private LaunchChecklistApp() { } @@ -22,12 +27,12 @@ public static void main(String[] args) { for (int index = 0; index < readiness.length; index++) { final boolean ready = readiness[index].booleanValue(); final String status = ready ? "ready" : "waiting"; - System.out.printf("%s: %s%n", steps[index], status); + LOGGER.info("{}: {}", steps[index], status); if (ready) { readyCount++; } } - System.out.printf("Summary: %d of %d steps are ready%n", readyCount, readiness.length); + LOGGER.info("Summary: {} of {} steps are ready", readyCount, readiness.length); } }