@Test(timeout = 5000) public void testFivePlusFiveWithoutFollowWillSkipFiveLastRecords() { ToolOptions options = ToolOptions.builder().withPath(DEFAULT_PATH).build(); LogPrinter printer = givenPrinter(options, 10); QueueReader reader = givenRecords(false, 5, 5); printer.print(reader); verifySingleRecordsFromStartOfSequence(5); }
void print(QueueReader queueReader) { long printedRecords = 0; while (true) { while (isEligibleForPrint(queueReader, printedRecords)) { StoredAuditRecord auditEntry = queueReader.nextRecord(); String logText = String.format(messageFormatter.getLogTemplate(), messageFormatter.getArgumentsForEntry(auditEntry)); out.println(logText); printedRecords++; } if (isLimitReached(printedRecords)) { return; } if (!toolOptions.follow()) { return; } try { Thread.sleep(pollIntervalMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } }
LogPrinter { void print(QueueReader queueReader) { long printedRecords = 0; while (true) { while (isEligibleForPrint(queueReader, printedRecords)) { StoredAuditRecord auditEntry = queueReader.nextRecord(); String logText = String.format(messageFormatter.getLogTemplate(), messageFormatter.getArgumentsForEntry(auditEntry)); out.println(logText); printedRecords++; } if (isLimitReached(printedRecords)) { return; } if (!toolOptions.follow()) { return; } try { Thread.sleep(pollIntervalMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } } }
LogPrinter { void print(QueueReader queueReader) { long printedRecords = 0; while (true) { while (isEligibleForPrint(queueReader, printedRecords)) { StoredAuditRecord auditEntry = queueReader.nextRecord(); String logText = String.format(messageFormatter.getLogTemplate(), messageFormatter.getArgumentsForEntry(auditEntry)); out.println(logText); printedRecords++; } if (isLimitReached(printedRecords)) { return; } if (!toolOptions.follow()) { return; } try { Thread.sleep(pollIntervalMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } } LogPrinter(ToolOptions toolOptions);   LogPrinter(ToolOptions toolOptions, PrintStream out, long pollIntervalMs, EcLogYamlConfig config); }
LogPrinter { void print(QueueReader queueReader) { long printedRecords = 0; while (true) { while (isEligibleForPrint(queueReader, printedRecords)) { StoredAuditRecord auditEntry = queueReader.nextRecord(); String logText = String.format(messageFormatter.getLogTemplate(), messageFormatter.getArgumentsForEntry(auditEntry)); out.println(logText); printedRecords++; } if (isLimitReached(printedRecords)) { return; } if (!toolOptions.follow()) { return; } try { Thread.sleep(pollIntervalMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } } LogPrinter(ToolOptions toolOptions);   LogPrinter(ToolOptions toolOptions, PrintStream out, long pollIntervalMs, EcLogYamlConfig config);  }
LogPrinter { void print(QueueReader queueReader) { long printedRecords = 0; while (true) { while (isEligibleForPrint(queueReader, printedRecords)) { StoredAuditRecord auditEntry = queueReader.nextRecord(); String logText = String.format(messageFormatter.getLogTemplate(), messageFormatter.getArgumentsForEntry(auditEntry)); out.println(logText); printedRecords++; } if (isLimitReached(printedRecords)) { return; } if (!toolOptions.follow()) { return; } try { Thread.sleep(pollIntervalMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } } LogPrinter(ToolOptions toolOptions);   LogPrinter(ToolOptions toolOptions, PrintStream out, long pollIntervalMs, EcLogYamlConfig config);   }