Added an extra option to the logger class to display the method result while measuring performance

This commit is contained in:
Andras Fuchs 2020-02-04 14:37:18 +01:00
parent 760b44d9f9
commit ba9c6a24c0
1 changed files with 6 additions and 1 deletions

View File

@ -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.");
}
}