Paper/src/main/java/net/minecraft/server/ConsoleLogManager.java

51 lines
1.6 KiB
Java
Raw Normal View History

package net.minecraft.server;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
2011-03-23 16:39:25 +01:00
// CraftBukkit start
2011-03-31 22:40:00 +02:00
import java.text.SimpleDateFormat;
2011-03-23 16:39:25 +01:00
import java.util.logging.Handler;
import org.bukkit.craftbukkit.util.ShortConsoleLogFormatter;
import org.bukkit.craftbukkit.util.TerminalConsoleHandler;
2011-03-23 16:39:25 +01:00
// CraftBukkit end
2011-02-23 13:56:36 +01:00
public class ConsoleLogManager {
public static Logger a = Logger.getLogger("Minecraft");
2011-02-23 13:56:36 +01:00
public static Logger global = Logger.getLogger(""); // CraftBukkit
public ConsoleLogManager() {}
// Craftbukkit - change of method signature!
public static void init(MinecraftServer server) {
ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter();
a.setUseParentHandlers(false);
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-03-31 22:40:00 +02:00
ConsoleHandler consolehandler = new TerminalConsoleHandler(server.reader);
2011-02-23 13:56:36 +01:00
for (Handler handler: global.getHandlers()) {
global.removeHandler(handler);
}
2011-03-31 22:40:00 +02:00
consolehandler.setFormatter(new ShortConsoleLogFormatter(server));
global.addHandler(consolehandler);
// CraftBukkit end
a.addHandler(consolehandler);
try {
FileHandler filehandler = new FileHandler("server.log", true);
filehandler.setFormatter(consolelogformatter);
a.addHandler(filehandler);
2011-02-23 13:56:36 +01:00
global.addHandler(filehandler); // CraftBukkit
} catch (Exception exception) {
a.log(Level.WARNING, "Failed to log to server.log", exception);
}
}
2011-02-23 13:56:36 +01:00
}