From bd3346e3cd5c954afc02c705e2e9fa511150494e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 27 May 2024 20:02:16 -0500 Subject: [PATCH] Take into account offset, make JavaDocs more descriptive --- .../dev/magicmq/pyspigot/util/logging/PrintStreamWrapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/magicmq/pyspigot/util/logging/PrintStreamWrapper.java b/src/main/java/dev/magicmq/pyspigot/util/logging/PrintStreamWrapper.java index 8b322d8..f0c5074 100644 --- a/src/main/java/dev/magicmq/pyspigot/util/logging/PrintStreamWrapper.java +++ b/src/main/java/dev/magicmq/pyspigot/util/logging/PrintStreamWrapper.java @@ -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);