Use log4j2 since it is now provided by default.

This commit is contained in:
Christian 2013-12-16 11:01:10 -05:00 committed by Erik Broes
parent 12bb371e68
commit 46401b94ac
4 changed files with 32 additions and 26 deletions

View file

@ -1,5 +1,6 @@
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
maven {
@ -16,6 +17,8 @@ dependencies {
compile 'net.sf.jopt-simple:jopt-simple:4.5'
compile 'org.ow2.asm:asm-debug-all:4.1'
compile 'org.lwjgl.lwjgl:lwjgl:2.8.5'
compile 'org.apache.logging.log4j:log4j-core:2.0-beta9'
compile 'org.apache.logging.log4j:log4j-api:2.0-beta9'
}
task sourcesJar(type: Jar) {

View file

@ -15,7 +15,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import org.apache.logging.log4j.Level;
public class Launch {
private static final String DEFAULT_TWEAK = "net.minecraft.launchwrapper.VanillaTweaker";
@ -82,7 +83,7 @@ public class Launch {
final String tweakName = it.next();
// Safety check - don't reprocess something we've already visited
if (allTweakerNames.contains(tweakName)) {
LogWrapper.log(Level.WARNING, "Tweak class name %s has already been visited -- skipping", tweakName);
LogWrapper.log(Level.WARN, "Tweak class name %s has already been visited -- skipping", tweakName);
// remove the tweaker from the stack otherwise it will create an infinite loop
it.remove();
continue;
@ -132,7 +133,7 @@ public class Launch {
LogWrapper.info("Launching wrapped minecraft {%s}", launchTarget);
mainMethod.invoke(null, (Object) argumentList.toArray(new String[argumentList.size()]));
} catch (Exception e) {
LogWrapper.log(Level.SEVERE, e, "Unable to launch");
LogWrapper.log(Level.ERROR, e, "Unable to launch");
}
}
}

View file

@ -13,7 +13,8 @@ import java.util.jar.Attributes.Name;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.logging.Level;
import org.apache.logging.log4j.Level;
public class LaunchClassLoader extends URLClassLoader {
public static final int BUFFER_SIZE = 1 << 12;
@ -87,7 +88,7 @@ public class LaunchClassLoader extends URLClassLoader {
renameTransformer = (IClassNameTransformer) transformer;
}
} catch (Exception e) {
LogWrapper.log(Level.SEVERE, e, "A critical problem occurred registering the ASM transformer class %s", transformerClassName);
LogWrapper.log(Level.ERROR, e, "A critical problem occurred registering the ASM transformer class %s", transformerClassName);
}
}
@ -181,7 +182,7 @@ public class LaunchClassLoader extends URLClassLoader {
} catch (Throwable e) {
invalidClasses.add(name);
if (DEBUG) {
LogWrapper.log(Level.FINEST, e, "Exception encountered attempting classloading of %s", name);
LogWrapper.log(Level.TRACE, e, "Exception encountered attempting classloading of %s", name);
}
throw new ClassNotFoundException(name, e);
}
@ -210,7 +211,7 @@ public class LaunchClassLoader extends URLClassLoader {
output.write(data);
output.close();
} catch (IOException ex) {
LogWrapper.log(Level.WARNING, ex, "Could not save transformed class \"%s\"", transformedName);
LogWrapper.log(Level.WARN, ex, "Could not save transformed class \"%s\"", transformedName);
}
}
@ -308,7 +309,7 @@ public class LaunchClassLoader extends URLClassLoader {
System.arraycopy(buffer, 0, result, 0, totalLength);
return result;
} catch (Throwable t) {
LogWrapper.log(Level.WARNING, t, "Problem loading class");
LogWrapper.log(Level.WARN, t, "Problem loading class");
return new byte[0];
}
}

View file

@ -1,7 +1,8 @@
package net.minecraft.launchwrapper;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LogWrapper {
public static LogWrapper log = new LogWrapper();
@ -10,7 +11,7 @@ public class LogWrapper {
private static boolean configured;
private static void configureLogging() {
log.myLog = Logger.getLogger("LaunchWrapper");
log.myLog = LogManager.getLogger("LaunchWrapper");
configured = true;
}
@ -19,7 +20,7 @@ public class LogWrapper {
}
public static void log(String logChannel, Level level, String format, Object... data) {
makeLog(logChannel);
Logger.getLogger(logChannel).log(level, String.format(format, data));
LogManager.getLogger(logChannel).log(level, String.format(format, data));
}
public static void log(Level level, String format, Object... data) {
@ -31,7 +32,7 @@ public class LogWrapper {
public static void log(String logChannel, Level level, Throwable ex, String format, Object... data) {
makeLog(logChannel);
Logger.getLogger(logChannel).log(level, String.format(format, data), ex);
LogManager.getLogger(logChannel).log(level, String.format(format, data), ex);
}
public static void log(Level level, Throwable ex, String format, Object... data) {
@ -42,11 +43,11 @@ public class LogWrapper {
}
public static void severe(String format, Object... data) {
log(Level.SEVERE, format, data);
log(Level.ERROR, format, data);
}
public static void warning(String format, Object... data) {
log(Level.WARNING, format, data);
log(Level.WARN, format, data);
}
public static void info(String format, Object... data) {
@ -54,18 +55,18 @@ public class LogWrapper {
}
public static void fine(String format, Object... data) {
log(Level.FINE, format, data);
log(Level.DEBUG, format, data);
}
public static void finer(String format, Object... data) {
log(Level.FINER, format, data);
log(Level.TRACE, format, data);
}
public static void finest(String format, Object... data) {
log(Level.FINEST, format, data);
log(Level.TRACE, format, data);
}
public static void makeLog(String logChannel) {
Logger.getLogger(logChannel).setParent(log.myLog);
LogManager.getLogger(logChannel);
}
}