Skip to content

Commit

Permalink
Take into account offset, make JavaDocs more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmq committed May 28, 2024
1 parent a27572c commit bd3346e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public PrintStreamWrapper(OutputStream out, Script script, Level level, String p
}

/**
* Captures writes to the PrintStream, converts the bytes into readable text, and logs the text to the script's logger
* Captures writes to the PrintStream, converts the bytes into readable text (truncating according to the specified length and offset), and logs the text to the script's logger. This method also strips carriage returns/new line characters from the end of the text, because the script logger already inserts a new line when logging.
* @param buf A byte array
* @param off Offset from which to start taking bytes
* @param len Number of bytes to write
*/
@Override
public void write(byte[] buf, int off, int len) {
byte[] toLog = Arrays.copyOfRange(buf, 0, len);
byte[] toLog = Arrays.copyOfRange(buf, off, 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 bd3346e

Please sign in to comment.