2011-02-20 03:14:15 +01:00
|
|
|
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
|
|
|
|
import java.util.logging.Handler;
|
2011-02-25 17:12:38 +01:00
|
|
|
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
|
|
|
|
2011-02-20 03:14:15 +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
|
2011-02-20 03:14:15 +01:00
|
|
|
|
|
|
|
public ConsoleLogManager() {}
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - change of method signature!
|
2011-04-20 19:05:14 +02:00
|
|
|
public static void init(MinecraftServer server) {
|
2011-02-20 03:14:15 +01:00
|
|
|
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()) {
|
2011-02-20 03:14:15 +01:00
|
|
|
global.removeHandler(handler);
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
consolehandler.setFormatter(new ShortConsoleLogFormatter(server));
|
|
|
|
global.addHandler(consolehandler);
|
|
|
|
// CraftBukkit end
|
2011-04-20 19:05:14 +02:00
|
|
|
|
2011-02-20 03:14:15 +01:00
|
|
|
a.addHandler(consolehandler);
|
|
|
|
|
|
|
|
try {
|
2011-07-10 19:28:57 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
String pattern = (String)server.options.valueOf("log-pattern");
|
|
|
|
int limit = ((Integer)server.options.valueOf("log-limit")).intValue();
|
|
|
|
int count = ((Integer)server.options.valueOf("log-count")).intValue();
|
|
|
|
boolean append = ((Boolean)server.options.valueOf("log-append")).booleanValue();
|
|
|
|
FileHandler filehandler = new FileHandler(pattern, limit, count, append);
|
2012-01-12 19:43:34 +01:00
|
|
|
// CraftBukkit end
|
2011-02-20 03:14:15 +01:00
|
|
|
|
|
|
|
filehandler.setFormatter(consolelogformatter);
|
|
|
|
a.addHandler(filehandler);
|
2011-02-23 13:56:36 +01:00
|
|
|
global.addHandler(filehandler); // CraftBukkit
|
2011-02-20 03:14:15 +01:00
|
|
|
} catch (Exception exception) {
|
|
|
|
a.log(Level.WARNING, "Failed to log to server.log", exception);
|
|
|
|
}
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
}
|