From ba9c6a24c0b06d00db4b2e262da9ebb0646cd705 Mon Sep 17 00:00:00 2001 From: Andras Fuchs Date: Tue, 4 Feb 2020 14:37:18 +0100 Subject: [PATCH] Added an extra option to the logger class to display the method result while measuring performance --- src/main/java/eu/mihosoft/freerouting/logger/FRLogger.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/mihosoft/freerouting/logger/FRLogger.java b/src/main/java/eu/mihosoft/freerouting/logger/FRLogger.java index f9be437..4fdf32a 100644 --- a/src/main/java/eu/mihosoft/freerouting/logger/FRLogger.java +++ b/src/main/java/eu/mihosoft/freerouting/logger/FRLogger.java @@ -29,6 +29,11 @@ public class FRLogger { } public static void traceExit(String perfId) + { + traceExit(perfId, null); + } + + public static void traceExit(String perfId, Object result) { var timeElapsed = Duration.between(perfData.get(perfId.hashCode()), java.time.Instant.now()).toMillis(); @@ -36,6 +41,6 @@ public class FRLogger { if (timeElapsed < 0) { timeElapsed = 0; } - logger.trace("Method '" + perfId + "' was performed in " + performanceFormat.format(timeElapsed/1000.0) + " seconds."); + logger.trace("Method '" + perfId.replace("{}", result != null ? result.toString() : "(null)") + "' was performed in " + performanceFormat.format(timeElapsed/1000.0) + " seconds."); } }