Skip to content

Commit

Permalink
feat: bridge logging to log4j
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Dec 14, 2021
1 parent 42c8150 commit 4cb792d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/kotlin/org/meowcat/mesagisto/farbic/Extension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.meowcat.mesagisto.farbic

import org.meowcat.mesagisto.client.ILogger
import org.meowcat.mesagisto.client.LogLevel
import org.meowcat.mesagisto.client.Logger

typealias StdLogger = org.apache.logging.log4j.Logger

fun Logger.bridgeToLog4j(impl: StdLogger) {
level = when (impl.level) {
// Level.ALL -> LogLevel.TRACE
// Level.FINE -> LogLevel.TRACE
// Level.INFO -> LogLevel.TRACE
// Level.WARNING -> LogLevel.WARN
// Level.SEVERE -> LogLevel.ERROR
// Level.OFF -> LogLevel.ERROR
else -> { LogLevel.TRACE }
}
provider = object : ILogger {
override fun log(level: LogLevel, msg: String) {
when (level) {
// LogLevel.TRACE -> impl.fine(msg)
// LogLevel.DEBUG -> impl.finer(msg)
LogLevel.INFO -> impl.info(msg)
else -> impl.info(msg)
}
}
}
}

0 comments on commit 4cb792d

Please sign in to comment.