aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Collins <travistx@gmail.com>2025-03-12 12:29:47 -0600
committersonartech <sonartech@sonarsource.com>2025-03-12 20:03:12 +0000
commit1d76a5e4176ca2715475781896a3c1bdfa8558ab (patch)
treefcc3b9e81c364f46d3284faeaebd5b3c23080b84
parentfa177566668e6d98c7cae8ba588983d03bc5415a (diff)
downloadsonarqube-1d76a5e4176ca2715475781896a3c1bdfa8558ab.tar.gz
sonarqube-1d76a5e4176ca2715475781896a3c1bdfa8558ab.zip
SCA-121 make sonar.sca.debug affect the debug logs
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java
index c2a474c4e52..7ee00d8e08f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.platform.Server;
import org.sonar.api.utils.System2;
@@ -60,8 +61,7 @@ public class CliService {
long startTime = system2.now();
boolean success = false;
try {
- Consumer<String> stdErrConsumer = LOG::debug;
- Consumer<String> stdoutConsumer = LOG::debug;
+ var debugLevel = Level.DEBUG;
String zipName = "dependency-files.zip";
Path zipPath = module.getWorkDir().resolve(zipName);
@@ -81,12 +81,11 @@ public class CliService {
args.add("--debug");
if (scaDebug) {
// output --debug logs from stderr to the info level logger
- stdErrConsumer = LOG::info;
- stdoutConsumer = LOG::info;
+ debugLevel = Level.INFO;
}
}
- LOG.debug("Calling ProcessBuilder with args: {}", args);
+ LOG.atLevel(debugLevel).log("Calling ProcessBuilder with args: {}", args);
Map<String, String> envProperties = new HashMap<>();
// sending this will tell the CLI to skip checking for the latest available version on startup
@@ -96,9 +95,10 @@ public class CliService {
envProperties.put("TIDELIFT_CLI_SQ_SERVER_VERSION", server.getVersion());
envProperties.putAll(ScaProperties.buildFromScannerProperties(configuration));
- LOG.debug("Environment properties: {}", envProperties);
+ LOG.atLevel(debugLevel).log("Environment properties: {}", envProperties);
- processWrapperFactory.create(module.getWorkDir(), stdoutConsumer, stdErrConsumer, envProperties, args.toArray(new String[0])).execute();
+ Consumer<String> logConsumer = LOG.atLevel(debugLevel)::log;
+ processWrapperFactory.create(module.getWorkDir(), logConsumer, logConsumer, envProperties, args.toArray(new String[0])).execute();
LOG.info("Generated manifests zip file: {}", zipName);
success = true;
return zipPath.toFile();