소스 검색

logging the delay of executing task

Lukas Cerny 4 년 전
부모
커밋
5267b3107c
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  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(() -> {