From 6dcbc8eb66ca2724a668c0fe80bdf89f88edbf7e Mon Sep 17 00:00:00 2001 From: sk89q Date: Mon, 14 Jul 2014 22:50:45 -0700 Subject: [PATCH] Fix a confusion of loggers for command logging. --- .../extension/platform/CommandManager.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index 49b21d797..85cb40134 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -65,7 +65,8 @@ import static com.google.common.base.Preconditions.checkNotNull; public final class CommandManager { public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+"); - private static final Logger logger = Logger.getLogger(CommandManager.class.getCanonicalName()); + private static final Logger log = Logger.getLogger(CommandManager.class.getCanonicalName()); + private static final Logger commandLog = Logger.getLogger(CommandManager.class.getCanonicalName() + ".CommandLog"); private static final java.util.regex.Pattern numberFormatExceptionPattern = java.util.regex.Pattern.compile("^For input string: \"(.*)\"$"); private final WorldEdit worldEdit; @@ -88,7 +89,7 @@ public final class CommandManager { worldEdit.getEventBus().register(this); // Setup the logger - logger.addHandler(dynamicHandler); + commandLog.addHandler(dynamicHandler); dynamicHandler.setFormatter(new LogFormat()); // Set up the commands manager @@ -98,7 +99,7 @@ public final class CommandManager { builder.addBinding(new WorldEditBinding(worldEdit)); builder.addExceptionConverter(new WorldEditExceptionConverter(worldEdit)); builder.addInvokeListener(new LegacyCommandsHandler()); - builder.addInvokeListener(new CommandLoggingHandler(worldEdit, logger)); + builder.addInvokeListener(new CommandLoggingHandler(worldEdit, commandLog)); dispatcher = new CommandGraph() .builder(builder) @@ -146,7 +147,7 @@ public final class CommandManager { } void register(Platform platform) { - logger.log(Level.FINE, "Registering commands with " + platform.getClass().getCanonicalName()); + log.log(Level.FINE, "Registering commands with " + platform.getClass().getCanonicalName()); LocalConfiguration config = platform.getConfiguration(); boolean logging = config.logCommands; @@ -155,18 +156,17 @@ public final class CommandManager { // Register log if (!logging || path.isEmpty()) { dynamicHandler.setHandler(null); - logger.setLevel(Level.OFF); + commandLog.setLevel(Level.OFF); } else { File file = new File(config.getWorkingDirectory(), path); + commandLog.setLevel(Level.ALL); - logger.setLevel(Level.ALL); - - logger.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath()); + log.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath()); try { dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true)); } catch (IOException e) { - logger.log(Level.WARNING, "Could not use command log file " + path + ": " + e.getMessage()); + log.log(Level.WARNING, "Could not use command log file " + path + ": " + e.getMessage()); } } @@ -241,14 +241,14 @@ public final class CommandManager { Throwable t = e.getCause(); actor.printError("Please report this error: [See console]"); actor.printRaw(t.getClass().getName() + ": " + t.getMessage()); - logger.log(Level.SEVERE, "An unexpected error while handling a WorldEdit command", t); + log.log(Level.SEVERE, "An unexpected error while handling a WorldEdit command", t); } catch (CommandException e) { String message = e.getMessage(); if (message != null) { actor.printError(e.getMessage()); } else { actor.printError("An unknown error has occurred! Please see console."); - logger.log(Level.SEVERE, "An unknown error occurred", e); + log.log(Level.SEVERE, "An unknown error occurred", e); } } finally { EditSession editSession = locals.get(EditSession.class); @@ -298,7 +298,7 @@ public final class CommandManager { } public static Logger getLogger() { - return logger; + return commandLog; } }