Skip to content

Instantly share code, notes, and snippets.

View gmuth's full-sized avatar

Gerhard Muth gmuth

  • ipp-software.com
  • Stuttgart, Germany
View GitHub Profile
@gmuth
gmuth / Slf4jExtension.kt
Last active January 19, 2021 09:31
Kotlin extension for Slf4j
package org.slf4j
enum class LogLevel { TRACE, DEBUG, INFO, WARN, ERROR }
fun Logger.trace(messageProducer: () -> Any?) = log(LogLevel.TRACE, null, messageProducer)
fun Logger.debug(messageProducer: () -> Any?) = log(LogLevel.DEBUG, null, messageProducer)
fun Logger.info(messageProducer: () -> Any?) = log(LogLevel.INFO, null, messageProducer)
fun Logger.warn(messageProducer: () -> Any?) = log(LogLevel.WARN, null, messageProducer)
fun Logger.error(messageProducer: () -> Any?) = log(LogLevel.ERROR, null, messageProducer)
fun Logger.trace(throwable: Throwable?, messageProducer: () -> Any?) = log(LogLevel.TRACE, throwable, messageProducer)