From 557fd1be24eb61f8c850345094a73b92bc4a2467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Sz=C3=BCcs?= Date: Sat, 15 Nov 2025 16:24:12 +0100 Subject: [PATCH] feat(util): enhance logging behavior in ProcessExecutor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Introduced `AtomicBoolean` to detect error messages dynamically - Changed logging to use `log.debug` for non-error lines and `log.info` for error-related lines during live updates - Improved error and output stream handling for better log verbosity and behaviour Signed-off-by: Balázs Szücs --- .../software/common/util/ProcessExecutor.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/app/common/src/main/java/stirling/software/common/util/ProcessExecutor.java b/app/common/src/main/java/stirling/software/common/util/ProcessExecutor.java index 9b260d9cf..823fcf757 100644 --- a/app/common/src/main/java/stirling/software/common/util/ProcessExecutor.java +++ b/app/common/src/main/java/stirling/software/common/util/ProcessExecutor.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import io.github.pixee.security.BoundedLineReader; @@ -175,6 +176,7 @@ public class ProcessExecutor { String messages = ""; int exitCode = 1; semaphore.acquire(); + AtomicBoolean errorDetected = new AtomicBoolean(false); try { log.info("Running command: {}", String.join(" ", command)); @@ -204,7 +206,16 @@ public class ProcessExecutor { errorReader, 5_000_000)) != null) { errorLines.add(line); - if (liveUpdates) log.info(line); + if (liveUpdates) { + if (line.toUpperCase().contains("ERROR")) { + errorDetected.set(true); + } + if (errorDetected.get()) { + log.info(line); + } else { + log.debug(line); + } + } } } catch (InterruptedIOException e) { log.warn("Error reader thread was interrupted due to timeout."); @@ -227,7 +238,16 @@ public class ProcessExecutor { outputReader, 5_000_000)) != null) { outputLines.add(line); - if (liveUpdates) log.info(line); + if (liveUpdates) { + if (line.toUpperCase().contains("ERROR")) { + errorDetected.set(true); + } + if (errorDetected.get()) { + log.info(line); + } else { + log.debug(line); + } + } } } catch (InterruptedIOException e) { log.warn("Error reader thread was interrupted due to timeout.");