package org.metaborg.util.log;

import org.slf4j.Logger;
import org.slf4j.helpers.MessageFormatter;

import javax.annotation.Nullable;

public class MetaborgLogger extends AbstractLogger {
    private final Logger logger;


    public MetaborgLogger(Logger logger) {
        this.logger = logger;
    }

    @Override public void trace(String msg, @Nullable Throwable t) {
        logger.trace(msg, t);
    }

    @Override public boolean traceEnabled() {
        return logger.isTraceEnabled();
    }

    @Override public void debug(String msg, @Nullable Throwable t) {
        logger.debug(msg, t);
    }

    @Override public boolean debugEnabled() {
        return logger.isDebugEnabled();
    }

    @Override public void info(String msg, @Nullable Throwable t) {
        logger.info(msg, t);
    }

    @Override public boolean infoEnabled() {
        return logger.isInfoEnabled();
    }

    @Override public void warn(String msg, @Nullable Throwable t) {
        logger.warn(msg, t);
    }

    @Override public boolean warnEnabled() {
        return logger.isWarnEnabled();
    }

    @Override public void error(String msg, @Nullable Throwable t) {
        logger.error(msg, t);
    }

    @Override public boolean errorEnabled() {
        return logger.isErrorEnabled();
    }

    @Override public String format(String fmt, Object... args) {
        return MessageFormatter.arrayFormat(fmt, args).getMessage();
    }
}

@@ -378,29 +378,116 @@
     
-logger.trace(msg, t);
+if (t != null) %7B%0A            logger.trace(msg, t);%0A        %7D else %7B%0A            logger.trace(msg);%0A        %7D
 %0A   
@@ -644,32 +644,61 @@
  Throwable t) %7B%0A
+        if (t != null) %7B%0A    
         logger.d
@@ -703,32 +703,90 @@
 .debug(msg, t);%0A
+        %7D else %7B%0A            logger.debug(msg);%0A        %7D%0A
     %7D%0A%0A    @Over
@@ -949,28 +949,114 @@
     
-logger.info(msg, t);
+if (t != null) %7B%0A            logger.info(msg, t);%0A        %7D else %7B%0A            logger.info(msg);%0A        %7D
 %0A   
@@ -1230,28 +1230,114 @@
     
-logger.warn(msg, t);
+if (t != null) %7B%0A            logger.warn(msg, t);%0A        %7D else %7B%0A            logger.warn(msg);%0A        %7D
 %0A   
@@ -1512,29 +1512,116 @@
     
-logger.error(msg, t);
+if (t != null) %7B%0A            logger.error(msg, t);%0A        %7D else %7B%0A            logger.error(msg);%0A        %7D
 %0A   

Fix NPE because of Slf4J throwable arg not being @Nullable