@Test(timeout = 5000) public void testCustomTimeFormat() { EcLogYamlConfig config = mockConfig("Timestamp = ${TIMESTAMP}, User = ${USER}, Status = ${STATUS}, Query = '${OPERATION}'"); when(config.getTimeFormatter()).thenReturn(Optional.of(DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneOffset.UTC))); LogPrinter printer = givenPrinterWithConfig(config); QueueReader reader = givenReaderWithSingleRecord(FULL_RECORD); printer.print(reader); verify(stream).println(eq("Timestamp = 1970-01-01T00:00:00.123, User = king, Status = ATTEMPT, Query = 'select something'")); }
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);   }