Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
Expand Down Expand Up @@ -142,22 +141,22 @@ public static String readWholeFileContent(String filePath) {

public static String rollViewLogLines(List<String> lines) {
StringBuilder builder = new StringBuilder();
final int MaxResponseLogSize = 65535;
int totalLogByteSize = 0;
final int MaxResponseLogCharSize = 65535;
int totalLogCharSize = 0;
for (String line : lines) {
// If a single line of log is exceed max response size, cut off the line
final int lineByteSize = line.getBytes(StandardCharsets.UTF_8).length;
if (lineByteSize >= MaxResponseLogSize) {
builder.append(line, 0, MaxResponseLogSize)
.append(" [this line's size ").append(lineByteSize).append(" bytes is exceed ")
.append(MaxResponseLogSize).append(" bytes, so only ")
.append(MaxResponseLogSize).append(" characters are reserved for performance reasons.]")
final int lineCharSize = line.length();
if (lineCharSize >= MaxResponseLogCharSize) {
builder.append(line, 0, MaxResponseLogCharSize)
.append(" [this line's size ").append(lineCharSize).append(" characters exceeds ")
.append(MaxResponseLogCharSize).append(" characters, so only ")
.append(MaxResponseLogCharSize).append(" characters are reserved for performance reasons.]")
.append("\r\n");
} else {
builder.append(line).append("\r\n");
}
totalLogByteSize += lineByteSize;
if (totalLogByteSize >= MaxResponseLogSize) {
totalLogCharSize += lineCharSize;
if (totalLogCharSize >= MaxResponseLogCharSize) {
break;
}
}
Expand Down
Loading