@Test(timeout = 5000) public void testAuthRecord() { ToolOptions options = ToolOptions.builder().withPath(DEFAULT_PATH).build(); LogPrinter printer = givenPrinter(options, 10); StoredAuditRecord authRecord = mockRecord(0L, "1.2.3.4", null, "5.6.7.8", "king", Status.ATTEMPT, null, "Authentication operation"); QueueReader reader = givenReaderWithSingleRecord(authRecord); printer.print(reader); verify(stream).println(eq("0|1.2.3.4|5.6.7.8|king|ATTEMPT|Authentication operation")); }
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);   }