Convert Slf4jFernflowerLogger to Kotlin

master
Graham 5 years ago
parent 01f30c5f03
commit aab286cf13
  1. 60
      decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.java
  2. 32
      decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.kt

@ -1,60 +0,0 @@
package dev.openrs2.decompiler;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class Slf4jFernflowerLogger extends IFernflowerLogger {
private static final Logger logger = LoggerFactory.getLogger(Slf4jFernflowerLogger.class);
public static final IFernflowerLogger INSTANCE = new Slf4jFernflowerLogger();
private Slf4jFernflowerLogger() {
/* empty */
}
@Override
public void startClass(String className) {
logger.info("Decompiling {}", className);
}
@Override
public void writeMessage(String message, Severity severity) {
switch (severity) {
case TRACE:
logger.trace(message);
break;
case INFO:
logger.info(message);
break;
case WARN:
logger.warn(message);
break;
case ERROR:
logger.error(message);
break;
default:
throw new IllegalArgumentException();
}
}
@Override
public void writeMessage(String message, Severity severity, Throwable t) {
switch (severity) {
case TRACE:
logger.trace(message, t);
break;
case INFO:
logger.info(message, t);
break;
case WARN:
logger.warn(message, t);
break;
case ERROR:
logger.error(message, t);
break;
default:
throw new IllegalArgumentException();
}
}
}

@ -0,0 +1,32 @@
package dev.openrs2.decompiler
import com.github.michaelbull.logging.InlineLogger
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger
object Slf4jFernflowerLogger : IFernflowerLogger() {
private val logger = InlineLogger()
override fun startClass(className: String) {
logger.info { "Decompiling $className" }
}
override fun writeMessage(message: String, severity: Severity) {
when (severity) {
Severity.TRACE -> logger.trace { message }
Severity.INFO -> logger.info { message }
Severity.WARN -> logger.warn { message }
Severity.ERROR -> logger.error { message }
else -> throw IllegalArgumentException()
}
}
override fun writeMessage(message: String, severity: Severity, t: Throwable) {
when (severity) {
Severity.TRACE -> logger.trace(t) { message }
Severity.INFO -> logger.info(t) { message }
Severity.WARN -> logger.warn(t) { message }
Severity.ERROR -> logger.error(t) { message }
else -> throw IllegalArgumentException()
}
}
}
Loading…
Cancel
Save