Skip to content

Instantly share code, notes, and snippets.

@tristanlins
Created April 24, 2019 13:58
Show Gist options
  • Save tristanlins/ab7da6d09a544e4d574612e255cf3110 to your computer and use it in GitHub Desktop.
Save tristanlins/ab7da6d09a544e4d574612e255cf3110 to your computer and use it in GitHub Desktop.
[kotlin] Create logger using extension function
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.reflect.KClass
fun <T : Any> KClass<T>.logger(): Logger {
return LoggerFactory.getLogger(this.java)
}
val LOG = MyClass::class.logger()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment