Skip to content

Commit

Permalink
Only capture printed text up to specified length and remove new line …
Browse files Browse the repository at this point in the history
…at end of string (new line is inserted by the script's logger)
  • Loading branch information
magicmq committed May 27, 2024
1 parent a2d821b commit 7e58d6a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.logging.Level;

/**
Expand Down Expand Up @@ -54,7 +55,9 @@ public PrintStreamWrapper(OutputStream out, Script script, Level level, String p
*/
@Override
public void write(byte[] buf, int off, int len) {
String string = new String(buf, StandardCharsets.UTF_8);
byte[] toLog = Arrays.copyOfRange(buf, 0, len);
String string = new String(toLog, StandardCharsets.UTF_8);
string = string.replaceAll("\\R$", "");
script.getLogger().log(level, prefix + " " + string);
}

Expand Down

0 comments on commit 7e58d6a

Please sign in to comment.