All Downloads are FREE. Search and download functionalities are using the official Maven repository.

s2.spring.utils.logger.Logger.kt Maven / Gradle / Ivy

package s2.spring.utils.logger

import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
import kotlin.reflect.full.companionObject
import org.slf4j.Logger
import org.slf4j.LoggerFactory

class Logger : ReadOnlyProperty {
	override fun getValue(thisRef: R, property: KProperty<*>) =
		LoggerFactory.getLogger(getClassForLogging(thisRef.javaClass))!!
}

fun  getClassForLogging(javaClass: Class): Class<*> {
	return javaClass.enclosingClass?.takeIf {
		it.kotlin.companionObject?.java == javaClass
	} ?: javaClass
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy