In java/groovy application I am using org.slf4j.Logger
I like to log method execution time and proposing to use following code
def startTime
LOGGER.isDebugEnabled() {
startTime = System.currentTimeMillis()
}
doSomething()
LOGGER.debug("Execution took {}ms", (System.currentTimeMillis() - startTime))
I think this code is ‘ugly’.
Can anyone suggest something more elegant ?
If you want to make the code look less ugly:
Change
to
I am not a fan of
isDebugEnabledfor these one liners. You will not see any performance difference without it.