- also log after a certain amount of time if processing is slow
This commit is contained in:
		@@ -87,15 +87,27 @@ public class FabianUtil {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      public void logIf() {
 | 
			
		||||
         if (counter.remainder(logDistance).signum() == 0) {
 | 
			
		||||
         if (counter.remainder(logDistance).signum() == 0 || isBored()) {
 | 
			
		||||
            log();
 | 
			
		||||
         }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      private boolean isBored() {
 | 
			
		||||
         ZonedDateTime time = lastLoggedAt == null ? startTime : lastLoggedAt;
 | 
			
		||||
         return time.until(ZonedDateTime.now(), ChronoUnit.SECONDS) >= timeLogDistance;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      public void log() {
 | 
			
		||||
         Duration timePassed = getTimePassed();
 | 
			
		||||
         System.out.println(counter + " Stück erledigt. " + formatDuration(timePassed) + " vergangen.");
 | 
			
		||||
         updateLastLoggedAt();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      protected void updateLastLoggedAt() {
 | 
			
		||||
         lastLoggedAt = ZonedDateTime.now();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -163,6 +175,7 @@ public class FabianUtil {
 | 
			
		||||
         String counterPrint = total.compareTo(BigDecimal.TEN) >= 0 ? formatNumber(counter) : counter.toString();
 | 
			
		||||
         System.out.println(counterPrint + " Stück von " + total + " (" + PERCENTAGE_FORMAT.format(percentage) + " %) erledigt. "
 | 
			
		||||
             + formatDuration(timePassed) + " vergangen" + remainingTimePart + ".");
 | 
			
		||||
         updateLastLoggedAt();
 | 
			
		||||
      }
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user