Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit c8f4cc6

Browse files
1.0.1 via 2.1
1 parent 6ece749 commit c8f4cc6

File tree

15 files changed

+99
-191
lines changed

15 files changed

+99
-191
lines changed

logger-slf4j/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ val compileKotlin: KotlinCompile by tasks
1414
val compileJava: JavaCompile by tasks
1515
compileJava.destinationDirectory.set(compileKotlin.destinationDirectory.get())
1616

17-
val slf4jVersion = "1.7.31"
17+
val slf4jVersion = "1.7.32"
1818

1919
dependencies {
2020
implementation(kotlin("reflect"))
2121
implementation(kotlin("stdlib"))
22-
compileOnly("com.github.OpenEdgn.Logger4K:logger-core:2.0.2")
22+
compileOnly("com.github.OpenEdgn.Logger4K:logger-core:2.1.0")
2323
compileOnly("org.slf4j:slf4j-api:$slf4jVersion")
2424
testImplementation("org.slf4j:slf4j-api:$slf4jVersion")
2525
testImplementation("ch.qos.logback:logback-core:1.2.5")
2626
testImplementation("ch.qos.logback:logback-core:1.2.5")
27-
testImplementation("com.github.OpenEdgn.Logger4K:logger-core:2.0.2")
2827
testImplementation("org.slf4j:slf4j-simple:$slf4jVersion")
28+
testImplementation("com.github.OpenEdgn.Logger4K:logger-core:2.1.0")
2929
testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
3030
testImplementation("org.junit.platform:junit-platform-launcher:1.6.2")
3131
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import logger.forward.slf4j.SLF4JLogApi;
2+
13
module logger4k.impl {
24
requires kotlin.stdlib;
35
requires logger4k.core;
46
requires kotlin.reflect;
57
requires org.slf4j;
6-
exports logger4k.impl.slf4j;
7-
opens logger4k.impl.slf4j to logger4k.core;
8-
provides com.github.openEdgn.logger4k.plugin.IPlugin with logger4k.LoggerPlugin;
9-
exports logger4k;
10-
opens logger4k to logger4k.core;
8+
exports logger.forward.slf4j;
9+
opens logger.forward.slf4j to logger4k.core;
10+
provides com.github.openEdgn.logger4k.api.ILogApi with SLF4JLogApi;
1111
}

logger-slf4j/src/main/kotlin/logger4k/impl/slf4j/Ext.kt renamed to logger-slf4j/src/main/kotlin/logger/forward/slf4j/Ext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* SOFTWARE.
1919
*/
2020

21-
package logger4k.impl.slf4j
21+
package logger.forward.slf4j
2222

2323
import org.slf4j.Logger
2424
import org.slf4j.LoggerFactory
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package logger.forward.slf4j
2+
3+
import com.github.openEdgn.logger4k.api.ILogApi
4+
import com.github.openEdgn.logger4k.api.ILogOutputApi
5+
6+
class SLF4JLogApi : ILogApi {
7+
8+
override val name = "SlF4JLog"
9+
10+
override fun init(): ILogOutputApi {
11+
return SLF4JLogOutputApi()
12+
}
13+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package logger.forward.slf4j
2+
3+
import com.github.openEdgn.logger4k.LoggerLevel
4+
import com.github.openEdgn.logger4k.api.ILogOutputApi
5+
import org.slf4j.Logger
6+
import org.slf4j.LoggerFactory
7+
import java.time.LocalDateTime
8+
9+
class SLF4JLogOutputApi : ILogOutputApi {
10+
11+
private fun getSLF4JLog(name: String): Logger {
12+
return LoggerFactory.getLogger(name)
13+
}
14+
15+
override fun outputLevel(name: String): LoggerLevel {
16+
val jLog = getSLF4JLog(name)
17+
return if (jLog.isTraceEnabled) {
18+
LoggerLevel.TRACE
19+
} else if (jLog.isDebugEnabled) {
20+
LoggerLevel.DEBUG
21+
} else if (jLog.isInfoEnabled) {
22+
LoggerLevel.INFO
23+
} else if (jLog.isWarnEnabled) {
24+
LoggerLevel.WARN
25+
} else if (jLog.isErrorEnabled) {
26+
LoggerLevel.ERROR
27+
} else {
28+
LoggerLevel.OFF
29+
}
30+
}
31+
32+
override fun outputLogger(name: String, thread: Thread, date: LocalDateTime, level: LoggerLevel, message: String) {
33+
getSLF4JLog(name).run {
34+
when (level) {
35+
LoggerLevel.TRACE -> trace(message)
36+
LoggerLevel.DEBUG -> debug(message)
37+
LoggerLevel.INFO -> info(message)
38+
LoggerLevel.WARN -> warn(message)
39+
LoggerLevel.ERROR -> error(message)
40+
LoggerLevel.OFF -> return
41+
}
42+
}
43+
}
44+
45+
override fun outputLogger(
46+
name: String,
47+
thread: Thread,
48+
date: LocalDateTime,
49+
level: LoggerLevel,
50+
message: String,
51+
exception: Throwable
52+
) {
53+
getSLF4JLog(name).run {
54+
when (level) {
55+
LoggerLevel.TRACE -> trace(message, exception)
56+
LoggerLevel.DEBUG -> debug(message, exception)
57+
LoggerLevel.INFO -> info(message, exception)
58+
LoggerLevel.WARN -> warn(message, exception)
59+
LoggerLevel.ERROR -> error(message, exception)
60+
LoggerLevel.OFF -> return
61+
}
62+
}
63+
}
64+
}

logger-slf4j/src/main/kotlin/logger4k/LoggerPlugin.kt

Lines changed: 0 additions & 63 deletions
This file was deleted.

logger-slf4j/src/main/kotlin/logger4k/impl/slf4j/SLF4JLogger.kt

Lines changed: 0 additions & 90 deletions
This file was deleted.

logger-slf4j/src/main/resources/META-INF/logger4k.properties

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
logger.forward.slf4j.SLF4JLogApi

logger-slf4j/src/test/kotlin/logger4k/impl/slf4j/SLF4JLoggerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package logger4k.impl.slf4j
2222

2323
import com.github.openEdgn.logger4k.LoggerFactory
24+
import logger.forward.slf4j.getSLF4JLogger
2425
import org.junit.jupiter.api.Test
2526
import org.slf4j.MarkerFactory
2627
import java.io.IOException
@@ -41,6 +42,7 @@ internal class SLF4JLoggerTest {
4142

4243
@Test
4344
fun testDebug() {
45+
println(logger.level)
4446
logger.debug("Hello World.")
4547
logger.debug("Hello World, {} .", "dragon")
4648
logger.debugThrowable("Exception", IOException())

0 commit comments

Comments
 (0)