From 71d7d8f791311ca388e607e73994e83c5bb28f44 Mon Sep 17 00:00:00 2001 From: "Christian F." Date: Thu, 26 Oct 2023 16:56:25 +0200 Subject: [PATCH] -refactor --- .../mediathek/tool/RuntimeStatistics.java | 36 ------------------ .../java/mediathek/tool/RuntimeStatistics.kt | 37 +++++++++++++++++++ 2 files changed, 37 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/mediathek/tool/RuntimeStatistics.java create mode 100644 src/main/java/mediathek/tool/RuntimeStatistics.kt diff --git a/src/main/java/mediathek/tool/RuntimeStatistics.java b/src/main/java/mediathek/tool/RuntimeStatistics.java deleted file mode 100644 index f22e04f569..0000000000 --- a/src/main/java/mediathek/tool/RuntimeStatistics.java +++ /dev/null @@ -1,36 +0,0 @@ -package mediathek.tool; - -import mediathek.tool.http.MVHttpClient; -import org.apache.logging.log4j.LogManager; - -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; - -public class RuntimeStatistics { - - public static final LocalDateTime startZeit = LocalDateTime.now(); - - /** - * Output runtime statistics to console and log file - */ - public static void printRuntimeStatistics() { - DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; - final var endZeit = LocalDateTime.now(); - final var runTime = LocalTime.MIN.plusSeconds(Duration.between(startZeit, endZeit).toSeconds()); - - var logger = LogManager.getLogger(); - logger.info("################################################################################"); - logger.info(" --> Start: {}", formatter.format(startZeit)); - logger.info(" --> Ende: {}", formatter.format(endZeit)); - logger.info(" --> Laufzeit: {}h {}m {}s", runTime.getHour(),runTime.getMinute(),runTime.getSecond()); - } - - public static void printDataUsageStatistics() { - var byteCounter = MVHttpClient.getInstance().getByteCounter(); - var logger = LogManager.getLogger(); - logger.info("total data sent: {}", FileUtils.humanReadableByteCountBinary(byteCounter.totalBytesWritten())); - logger.info("total data received: {}", FileUtils.humanReadableByteCountBinary(byteCounter.totalBytesRead())); - } -} diff --git a/src/main/java/mediathek/tool/RuntimeStatistics.kt b/src/main/java/mediathek/tool/RuntimeStatistics.kt new file mode 100644 index 0000000000..18b479420d --- /dev/null +++ b/src/main/java/mediathek/tool/RuntimeStatistics.kt @@ -0,0 +1,37 @@ +package mediathek.tool + +import mediathek.tool.FileUtils.humanReadableByteCountBinary +import mediathek.tool.http.MVHttpClient +import org.apache.logging.log4j.LogManager +import org.apache.logging.log4j.Logger +import java.time.Duration +import java.time.LocalDateTime +import java.time.LocalTime +import java.time.format.DateTimeFormatter + +object RuntimeStatistics { + @JvmField + val startZeit: LocalDateTime = LocalDateTime.now() + val logger: Logger = LogManager.getLogger() + + /** + * Output runtime statistics to console and log file + */ + @JvmStatic + fun printRuntimeStatistics() { + val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME + val endZeit = LocalDateTime.now() + val runTime = LocalTime.MIN.plusSeconds(Duration.between(startZeit, endZeit).toSeconds()) + + logger.info(" --> Start: ${formatter.format(startZeit)}") + logger.info(" --> Ende: ${formatter.format(endZeit)}") + logger.info(" --> Laufzeit: ${runTime.hour}h ${runTime.minute}m ${runTime.second}s") + } + + @JvmStatic + fun printDataUsageStatistics() { + val byteCounter = MVHttpClient.getInstance().byteCounter + logger.info("Total data sent: ${humanReadableByteCountBinary(byteCounter.totalBytesWritten())}") + logger.info("Total data received: ${humanReadableByteCountBinary(byteCounter.totalBytesRead())}") + } +}