From a09b476377f8e175db7ad8c76a9c79000c14c9ca Mon Sep 17 00:00:00 2001 From: Laurent Clouet <4409640-laurent.clouet@users.noreply.gitlab.com> Date: Sat, 13 Jul 2024 12:11:41 +0000 Subject: [PATCH] Fix: always save data in ram --- src/main/java/com/sheepit/client/Log.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sheepit/client/Log.java b/src/main/java/com/sheepit/client/Log.java index 7c86444..47a97ac 100644 --- a/src/main/java/com/sheepit/client/Log.java +++ b/src/main/java/com/sheepit/client/Log.java @@ -83,18 +83,22 @@ public final class Log { } private synchronized void append(int point_, String level_, String msg_) { - if (LEVEL_DEBUG.equals(level_) && this.debugLevel == false) { - return; - } - try { int checkpointToWrite = (point_ > 0 ? point_ : this.lastCheckPoint); if ("".equals(msg_) == false) { String line = this.dateFormat.format(new Date()) + " (" + level_ + ") " + msg_; + + // always add to memory if (this.checkpoints.containsKey(checkpointToWrite) && this.checkpoints.get(checkpointToWrite) != null) { this.checkpoints.get(checkpointToWrite).add(line); } + + // DEBUG mode for not always use stdout/file + if (LEVEL_DEBUG.equals(level_) && this.debugLevel == false) { + return; + } + if (this.printStdOut) { System.out.println(line); }