Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Fix a confusion of loggers for command logging.
Dieser Commit ist enthalten in:
Ursprung
e21b21d266
Commit
6dcbc8eb66
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren