From 4cb792dd2c8fe2dc3a137587401c37a684195d0e Mon Sep 17 00:00:00 2001 From: itsusinn Date: Tue, 14 Dec 2021 14:50:33 +0800 Subject: [PATCH] feat: bridge logging to log4j --- .../org/meowcat/mesagisto/farbic/Extension.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/kotlin/org/meowcat/mesagisto/farbic/Extension.kt diff --git a/src/main/kotlin/org/meowcat/mesagisto/farbic/Extension.kt b/src/main/kotlin/org/meowcat/mesagisto/farbic/Extension.kt new file mode 100644 index 0000000..daa4af3 --- /dev/null +++ b/src/main/kotlin/org/meowcat/mesagisto/farbic/Extension.kt @@ -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) + } + } + } +}