diff options
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/handler/LogReader.java')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/LogReader.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/LogReader.java b/container-core/src/main/java/com/yahoo/container/handler/LogReader.java index dae4b940307..93881b52eb6 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/LogReader.java +++ b/container-core/src/main/java/com/yahoo/container/handler/LogReader.java @@ -59,10 +59,9 @@ class LogReader { this.logFilePattern = logFilePattern; } - void writeLogs(OutputStream out, Instant from, Instant to, long maxLines, Optional<String> hostname) { + void writeLogs(OutputStream out, Instant from, Instant to, Optional<String> hostname) { double fromSeconds = from.getEpochSecond() + from.getNano() / 1e9; double toSeconds = to.getEpochSecond() + to.getNano() / 1e9; - long linesWritten = 0; BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); for (List<Path> logs : getMatchingFiles(from, to)) { List<LogLineIterator> logLineIterators = new ArrayList<>(); @@ -74,7 +73,6 @@ class LogReader { Iterator<LineWithTimestamp> lines = Iterators.mergeSorted(logLineIterators, Comparator.comparingDouble(LineWithTimestamp::timestamp)); while (lines.hasNext()) { - if (linesWritten++ >= maxLines) return; String line = lines.next().line(); writer.write(line); writer.newLine(); @@ -189,7 +187,16 @@ class LogReader { } - private record LineWithTimestamp(String line, double timestamp) { } + private static class LineWithTimestamp { + final String line; + final double timestamp; + LineWithTimestamp(String line, double timestamp) { + this.line = line; + this.timestamp = timestamp; + } + String line() { return line; } + double timestamp() { return timestamp; } + } /** Returns log files which may have relevant entries, grouped and sorted by {@link #extractTimestamp(Path)} — the first and last group must be filtered. */ private List<List<Path>> getMatchingFiles(Instant from, Instant to) { |