mirror of
https://github.com/tursom/TursomServer.git
synced 2025-01-06 10:20:14 +08:00
添加日志工具类
This commit is contained in:
parent
d9b7b3a5d4
commit
f2bd0d2ae3
4
log/build.gradle
Normal file
4
log/build.gradle
Normal file
@ -0,0 +1,4 @@
|
||||
dependencies {
|
||||
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: '1.3.61'
|
||||
compileOnly group: 'org.slf4j', name: 'slf4j-api', version: '1.7.29'
|
||||
}
|
9
log/src/main/kotlin/cn/tursom/log/Slf4j.kt
Normal file
9
log/src/main/kotlin/cn/tursom/log/Slf4j.kt
Normal file
@ -0,0 +1,9 @@
|
||||
package cn.tursom.log
|
||||
|
||||
import org.slf4j.Logger
|
||||
|
||||
interface Slf4j {
|
||||
val log: Logger
|
||||
val logger: Logger get() = log
|
||||
val sfl4j: Logger get() = log
|
||||
}
|
17
log/src/main/kotlin/cn/tursom/log/impl/Slf4jImpl.kt
Normal file
17
log/src/main/kotlin/cn/tursom/log/impl/Slf4jImpl.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package cn.tursom.log.impl
|
||||
|
||||
import cn.tursom.log.Slf4j
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import kotlin.reflect.jvm.jvmName
|
||||
|
||||
class Slf4jImpl(name: String? = null) : Slf4j {
|
||||
override val log: Logger = LoggerFactory.getLogger(name ?: if (this::class.java != Slf4jImpl::class.java) {
|
||||
val clazz = this::class
|
||||
clazz.jvmName.let {
|
||||
if (clazz.isCompanion) it.dropLast(10) else it
|
||||
}
|
||||
} else {
|
||||
throw NotImplementedError("")
|
||||
})
|
||||
}
|
@ -2,4 +2,5 @@ rootProject.name = 'TursomServer'
|
||||
include 'web', 'aop', 'database', 'database:database-async', 'utils', 'utils:xml', 'utils:async-http', 'web:netty-web'
|
||||
include 'socket', 'socket:socket-async'
|
||||
include 'AsyncSocket'
|
||||
include 'log'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dependencies {
|
||||
implementation project(":")
|
||||
compileOnly group: 'org.slf4j', name: 'slf4j-api', version: '1.7.29'
|
||||
compileOnly project(":log")
|
||||
}
|
Loading…
Reference in New Issue
Block a user