package net.aeronica.mods.mxtune.util;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;

public class ModLogger {

    private static Logger logger;

    public static void setLogger(Logger logger) {
        if (ModLogger.logger != null) {
            throw new IllegalStateException("Attempt to replace logger");
        }
        ModLogger.logger = logger;
    }

    public static void log(Level level, String format, Object... data) {
        for(Object obj : data)
        {
            if (obj instanceof Exception)
            {
                for(StackTraceElement ste : ((Exception) obj).getStackTrace())
                {
                    logger.printf(level, format, ste); 
                }
            } else
                logger.printf(level, format, data);
        }
    }

    public static void info(String format, Object... data){
        log(Level.INFO, format, data);
    }
    
    public static void debug(String format, Object... data){
        log(Level.DEBUG, format, data);
    }
    
    public static void warning(String format, Object... data){
        log(Level.WARN, format, data);
    }

    public static void error(String format, Object... data){
        log(Level.ERROR, format, data);
    }

    public static void fatal(String format, Object... data){
        log(Level.FATAL, format, data);
    }

    public static void info(Object... data){
        log(Level.INFO, "%s", data);
    }
    
    public static void debug(Object... data){
        log(Level.DEBUG, "%s", data);
    }
    
    public static void warning(Object... data){
        log(Level.WARN, "%s", data);
    }

    public static void error(Object... data){
        log(Level.ERROR, "%s", data);
    }

    public static void fatal(Object... data){
        log(Level.FATAL, "%s", data);
    }
    
}

@@ -467,303 +467,8 @@
 ) %7B%0A
-        for(Object obj : data)%0A        %7B%0A            if (obj instanceof Exception)%0A            %7B%0A                for(StackTraceElement ste : ((Exception) obj).getStackTrace())%0A                %7B%0A                    logger.printf(level, format, ste); %0A                %7D%0A            %7D else%0A        
     
@@ -511,25 +511,19 @@
 a);%0A
-        %7D%0A
     %7D%0A
+    
 %0A
-
     
@@ -1087,442 +1087,90 @@
 tic 
-void info(Object... data)%7B%0A        log(Level.INFO, %22%25s%22, data);%0A    %7D%0A    %0A    public static void debug(Object... data)%7B%0A        log(Level.DEBUG, %22%25s%22, data);
+%3CT extends Exception%3E void error(T e)
 %0A    
-%7D
+%7B
 %0A    
-%0A
     
-public static void warning(Object... data)%7B%0A        log(Level.WARN, %22%25s%22, data);%0A    %7D%0A%0A    public static void error(Object... data)%7B%0A        log(Level.ERROR, %22%25s%22, data);%0A    %7D%0A%0A    public static void fatal(Object... data)%7B%0A        log(Level.FATAL, %22%25s%22, data
+logger.error(e.getStackTrace()
 );%0A 
@@ -1174,15 +1174,10 @@
 ;%0A    %7D%0A
-    %0A
 %7D%0A

Fix ModLogger.