Browse Source

logging the delay of executing task

Lukas Cerny 4 years ago
parent
commit
5267b3107c
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/main/java/cz/senslog/watchdog/util/schedule/ScheduleTask.java

+ 8 - 1
src/main/java/cz/senslog/watchdog/util/schedule/ScheduleTask.java

@@ -1,6 +1,10 @@
 package cz.senslog.watchdog.util.schedule;
 
 
+import cz.senslog.watchdog.messagebroker.email.EmailMessageBroker;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
 import java.time.LocalDateTime;
 import java.time.temporal.ChronoUnit;
 import java.util.concurrent.CountDownLatch;
@@ -12,6 +16,8 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
 
 public final class ScheduleTask {
 
+    private static final Logger logger = LogManager.getLogger(EmailMessageBroker.class);
+
     private static final int DEFAULT_DELAY_MILLIS = 2_000; // 2s
 
     private TaskDescription description;
@@ -61,7 +67,8 @@ public final class ScheduleTask {
         } else if (delayMillis > 0) {
             delay = delayMillis;
         }
-        
+
+        logger.info("The task '{}' is going to be executed in {} ms.", description.getName(), delay);
         ScheduledFuture<?> future = scheduledService.scheduleAtFixedRate(task, delay, periodMillis, MILLISECONDS);
         description = new TaskDescription(description.getName(), Status.RUNNING);
         new Thread(() -> {