Gilles Barbier
08/21/2024, 10:09 PMnull
? I do not want to do expr?.<http://logger.info|logger.info> { it }
to avoid calculating the expr whatever the logging level.Szymon Jeziorski
08/22/2024, 8:36 AMclass NotNullLogger(private val logger: KLogger) : KLogger by logger {
override fun debug(msg: () -> Any?) {
if (isDebugEnabled) msg()?.let { logger.debug { it } }
}
[...]
}
fun NotNullLogger(func: () -> Unit) = NotNullLogger(KotlinLogging.logger(func))
val logger = NotNullLogger { }
logger.debug { some nullable expression }
Gilles Barbier
08/22/2024, 9:24 AM