@Test public void readTest() { final Logger logger = LoggerFactory.getLogger("binary-chronicle"); logger.info("test {} {} {}", 1, 100L, 100.123D); logger.info("test {} {} {}", 2, 100L, 100.123D); logger.info("test {} {} {}", 3, 100L, 100.123D); ChronicleLogReader reader = new ChronicleLogReader(System.getProperty("java.io.tmpdir") + "/chronicle-logback/binary-chronicle", WireType.BINARY_LIGHT); reader.processLogs(ChronicleLogReader::printf, false); }
public void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt) { ExcerptTailer tailer = cq.createTailer(); for (; ; ) { try (DocumentContext dc = tailer.readingDocument()) { Wire wire = dc.wire(); if (wire == null) if (waitForIt) { try { Thread.sleep(50L); } catch (InterruptedException ignored) { } continue; } else { break; } long timestamp = wire.read("ts").int64(); ChronicleLogLevel level = wire.read("level").asEnum(ChronicleLogLevel.class); String threadName = wire.read("threadName").text(); String loggerName = wire.read("loggerName").text(); String message = wire.read("message").text(); Throwable th = wire.hasMore() ? wire.read("throwable").throwable(false) : null; List<Object> argsL = new ArrayList<>(); if (wire.hasMore()) { wire.read("args").sequence(argsL, (l, vi) -> { while (vi.hasNextSequenceItem()) { l.add(vi.object(Object.class)); } }); } Object[] args = argsL.toArray(new Object[argsL.size()]); processor.process(timestamp, level, threadName, loggerName, message, th, args); } } }
ChronicleLogReader { public void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt) { ExcerptTailer tailer = cq.createTailer(); for (; ; ) { try (DocumentContext dc = tailer.readingDocument()) { Wire wire = dc.wire(); if (wire == null) if (waitForIt) { try { Thread.sleep(50L); } catch (InterruptedException ignored) { } continue; } else { break; } long timestamp = wire.read("ts").int64(); ChronicleLogLevel level = wire.read("level").asEnum(ChronicleLogLevel.class); String threadName = wire.read("threadName").text(); String loggerName = wire.read("loggerName").text(); String message = wire.read("message").text(); Throwable th = wire.hasMore() ? wire.read("throwable").throwable(false) : null; List<Object> argsL = new ArrayList<>(); if (wire.hasMore()) { wire.read("args").sequence(argsL, (l, vi) -> { while (vi.hasNextSequenceItem()) { l.add(vi.object(Object.class)); } }); } Object[] args = argsL.toArray(new Object[argsL.size()]); processor.process(timestamp, level, threadName, loggerName, message, th, args); } } } }
ChronicleLogReader { public void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt) { ExcerptTailer tailer = cq.createTailer(); for (; ; ) { try (DocumentContext dc = tailer.readingDocument()) { Wire wire = dc.wire(); if (wire == null) if (waitForIt) { try { Thread.sleep(50L); } catch (InterruptedException ignored) { } continue; } else { break; } long timestamp = wire.read("ts").int64(); ChronicleLogLevel level = wire.read("level").asEnum(ChronicleLogLevel.class); String threadName = wire.read("threadName").text(); String loggerName = wire.read("loggerName").text(); String message = wire.read("message").text(); Throwable th = wire.hasMore() ? wire.read("throwable").throwable(false) : null; List<Object> argsL = new ArrayList<>(); if (wire.hasMore()) { wire.read("args").sequence(argsL, (l, vi) -> { while (vi.hasNextSequenceItem()) { l.add(vi.object(Object.class)); } }); } Object[] args = argsL.toArray(new Object[argsL.size()]); processor.process(timestamp, level, threadName, loggerName, message, th, args); } } } ChronicleLogReader(
            @NotNull String path);  ChronicleLogReader(
            @NotNull String path,
            @NotNull WireType wireType); }
ChronicleLogReader { public void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt) { ExcerptTailer tailer = cq.createTailer(); for (; ; ) { try (DocumentContext dc = tailer.readingDocument()) { Wire wire = dc.wire(); if (wire == null) if (waitForIt) { try { Thread.sleep(50L); } catch (InterruptedException ignored) { } continue; } else { break; } long timestamp = wire.read("ts").int64(); ChronicleLogLevel level = wire.read("level").asEnum(ChronicleLogLevel.class); String threadName = wire.read("threadName").text(); String loggerName = wire.read("loggerName").text(); String message = wire.read("message").text(); Throwable th = wire.hasMore() ? wire.read("throwable").throwable(false) : null; List<Object> argsL = new ArrayList<>(); if (wire.hasMore()) { wire.read("args").sequence(argsL, (l, vi) -> { while (vi.hasNextSequenceItem()) { l.add(vi.object(Object.class)); } }); } Object[] args = argsL.toArray(new Object[argsL.size()]); processor.process(timestamp, level, threadName, loggerName, message, th, args); } } } ChronicleLogReader(
            @NotNull String path);  ChronicleLogReader(
            @NotNull String path,
            @NotNull WireType wireType); static void printf(
            long timestamp,
            ChronicleLogLevel level,
            String loggerName,
            String threadName,
            String message,
            @Nullable Throwable throwable,
            Object[] args); void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt); }
ChronicleLogReader { public void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt) { ExcerptTailer tailer = cq.createTailer(); for (; ; ) { try (DocumentContext dc = tailer.readingDocument()) { Wire wire = dc.wire(); if (wire == null) if (waitForIt) { try { Thread.sleep(50L); } catch (InterruptedException ignored) { } continue; } else { break; } long timestamp = wire.read("ts").int64(); ChronicleLogLevel level = wire.read("level").asEnum(ChronicleLogLevel.class); String threadName = wire.read("threadName").text(); String loggerName = wire.read("loggerName").text(); String message = wire.read("message").text(); Throwable th = wire.hasMore() ? wire.read("throwable").throwable(false) : null; List<Object> argsL = new ArrayList<>(); if (wire.hasMore()) { wire.read("args").sequence(argsL, (l, vi) -> { while (vi.hasNextSequenceItem()) { l.add(vi.object(Object.class)); } }); } Object[] args = argsL.toArray(new Object[argsL.size()]); processor.process(timestamp, level, threadName, loggerName, message, th, args); } } } ChronicleLogReader(
            @NotNull String path);  ChronicleLogReader(
            @NotNull String path,
            @NotNull WireType wireType); static void printf(
            long timestamp,
            ChronicleLogLevel level,
            String loggerName,
            String threadName,
            String message,
            @Nullable Throwable throwable,
            Object[] args); void processLogs(@NotNull ChronicleLogProcessor processor, boolean waitForIt);  }