
15 Feb
2007
15 Feb
'07
7:51 a.m.
Nick wrote:
/* Lazily compute the logger. The computation will not start running until the value of 'logger' is actually requested. */ var logger = lazy({ Logging.getLogger() })
/* This will start the computation */ logger.debug("medved")
/* No delay to compute the logger again, as it has already been calculated */ logger.debug("preved")
It seems you miss the point here: not only logger should be lazy, but all calls to logger's methods: logger.debug(formatLongMessage(args)); // formatLongMessage should not // waste CPU cycles if debug // logging is off