添加日志工具类

This commit is contained in:
tursom 2019-11-30 10:35:49 +08:00
parent 87aa8816bd
commit a7d6f4a211
2 changed files with 5 additions and 9 deletions

View File

@ -2,8 +2,8 @@ package cn.tursom.log
import org.slf4j.Logger
interface Slf4j {
val log: Logger
val logger get() = log
val sfl4j get() = log
interface Slf4j : TrySlf4j {
override val log: Logger
override val logger get() = log
override val sfl4j get() = log
}

View File

@ -1,13 +1,12 @@
package cn.tursom.log.impl
import cn.tursom.log.Slf4j
import cn.tursom.log.TrySlf4j
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.reflect.KClass
import kotlin.reflect.jvm.jvmName
class Slf4jImpl(name: String? = null) : Slf4j, TrySlf4j {
class Slf4jImpl(name: String? = null) : Slf4j {
constructor(clazz: Class<*>?) : this(clazz?.name)
constructor(clazz: KClass<*>?) : this(clazz?.jvmName?.let {
if (clazz.isCompanion) it.dropLast(10) else it
@ -21,7 +20,4 @@ class Slf4jImpl(name: String? = null) : Slf4j, TrySlf4j {
} else {
throw NotImplementedError("")
})
override val logger: Logger get() = log
override val sfl4j: Logger get() = log
}