mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-05 04:16:06 +00:00
Fix a confusion of loggers for command logging.
This commit is contained in:
parent
e21b21d266
commit
6dcbc8eb66
@ -65,7 +65,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
public final class CommandManager {
|
public final class CommandManager {
|
||||||
|
|
||||||
public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+");
|
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 static final java.util.regex.Pattern numberFormatExceptionPattern = java.util.regex.Pattern.compile("^For input string: \"(.*)\"$");
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
@ -88,7 +89,7 @@ public final class CommandManager {
|
|||||||
worldEdit.getEventBus().register(this);
|
worldEdit.getEventBus().register(this);
|
||||||
|
|
||||||
// Setup the logger
|
// Setup the logger
|
||||||
logger.addHandler(dynamicHandler);
|
commandLog.addHandler(dynamicHandler);
|
||||||
dynamicHandler.setFormatter(new LogFormat());
|
dynamicHandler.setFormatter(new LogFormat());
|
||||||
|
|
||||||
// Set up the commands manager
|
// Set up the commands manager
|
||||||
@ -98,7 +99,7 @@ public final class CommandManager {
|
|||||||
builder.addBinding(new WorldEditBinding(worldEdit));
|
builder.addBinding(new WorldEditBinding(worldEdit));
|
||||||
builder.addExceptionConverter(new WorldEditExceptionConverter(worldEdit));
|
builder.addExceptionConverter(new WorldEditExceptionConverter(worldEdit));
|
||||||
builder.addInvokeListener(new LegacyCommandsHandler());
|
builder.addInvokeListener(new LegacyCommandsHandler());
|
||||||
builder.addInvokeListener(new CommandLoggingHandler(worldEdit, logger));
|
builder.addInvokeListener(new CommandLoggingHandler(worldEdit, commandLog));
|
||||||
|
|
||||||
dispatcher = new CommandGraph()
|
dispatcher = new CommandGraph()
|
||||||
.builder(builder)
|
.builder(builder)
|
||||||
@ -146,7 +147,7 @@ public final class CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void register(Platform platform) {
|
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();
|
LocalConfiguration config = platform.getConfiguration();
|
||||||
boolean logging = config.logCommands;
|
boolean logging = config.logCommands;
|
||||||
@ -155,18 +156,17 @@ public final class CommandManager {
|
|||||||
// Register log
|
// Register log
|
||||||
if (!logging || path.isEmpty()) {
|
if (!logging || path.isEmpty()) {
|
||||||
dynamicHandler.setHandler(null);
|
dynamicHandler.setHandler(null);
|
||||||
logger.setLevel(Level.OFF);
|
commandLog.setLevel(Level.OFF);
|
||||||
} else {
|
} else {
|
||||||
File file = new File(config.getWorkingDirectory(), path);
|
File file = new File(config.getWorkingDirectory(), path);
|
||||||
|
commandLog.setLevel(Level.ALL);
|
||||||
|
|
||||||
logger.setLevel(Level.ALL);
|
log.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath());
|
||||||
|
|
||||||
logger.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true));
|
dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true));
|
||||||
} catch (IOException e) {
|
} 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();
|
Throwable t = e.getCause();
|
||||||
actor.printError("Please report this error: [See console]");
|
actor.printError("Please report this error: [See console]");
|
||||||
actor.printRaw(t.getClass().getName() + ": " + t.getMessage());
|
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) {
|
} catch (CommandException e) {
|
||||||
String message = e.getMessage();
|
String message = e.getMessage();
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
actor.printError(e.getMessage());
|
actor.printError(e.getMessage());
|
||||||
} else {
|
} else {
|
||||||
actor.printError("An unknown error has occurred! Please see console.");
|
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 {
|
} finally {
|
||||||
EditSession editSession = locals.get(EditSession.class);
|
EditSession editSession = locals.get(EditSession.class);
|
||||||
@ -298,7 +298,7 @@ public final class CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Logger getLogger() {
|
public static Logger getLogger() {
|
||||||
return logger;
|
return commandLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user