Skip to content

Commit

Permalink
chore: Disable color logging when writing integration logs to dump file
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed Jun 13, 2024
1 parent fb30c57 commit 8134237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand Down Expand Up @@ -114,6 +115,12 @@ public ProcessAndOutput run(String name, String file, String... args) {
if (CamelJBangSettings.isCamelDumpIntegrationOutput()) {
Path workDir = CamelJBangSettings.getWorkDir();
File outputFile = workDir.resolve(String.format("i-%s-output.txt", name)).toFile();

if (Stream.of(args).noneMatch(it -> it.contains("--logging-color"))) {
// disable logging colors when writing logs to file
runArgs.add("--logging-color=false");
}

return executeAsync(camel(runArgs.toArray(String[]::new)), outputFile);
} else {
return executeAsync(camel(runArgs.toArray(String[]::new)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void readAllAndClose() {
builder.append(line).append(System.lineSeparator());
}

if (builder.length() > 0) {
if (!builder.isEmpty()) {
output += builder;
}
} catch (IOException e) {
Expand Down Expand Up @@ -124,7 +124,7 @@ private void readChunk() {
throw new CitrusRuntimeException("Failed to get JBang process output", e);
}

if (builder.length() > 0) {
if (!builder.isEmpty()) {
if (output == null) {
output = builder.toString();
} else {
Expand Down

0 comments on commit 8134237

Please sign in to comment.