Andreas Sinz
05/30/2018, 10:46 AMinterface TLogger {
fun debug(tag: String, msg: () -> String)
}
class MyLogger : TLogger {
override fun debug(tag: String, msg: () -> String) {
writeLogLine( "//DateTime \t tag \t ${ msg() }") //Logger formats the whole log-line
}
}
//Consumer
logger.debug("HERE", { "Result: ${ doHeavyComputation() }") //Client just tells the Logger how to create the expensive message, not how to format the log-line