Death to ACFLog (#42)

This commit is contained in:
kashike
2017-06-06 16:03:01 -07:00
committed by Daniel Ennis
parent cd892fccd4
commit 96a3a3c57d
14 changed files with 107 additions and 124 deletions
@@ -23,6 +23,7 @@
package co.aikar.commands;
import co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil;
import co.aikar.timings.Timing;
import co.aikar.timings.Timings;
import org.spongepowered.api.Sponge;
@@ -119,4 +120,29 @@ public class SpongeCommandManager extends CommandManager {
public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) {
return new RegisteredCommand(command, cmdName, method, prefSubCommand);
}
@Override
public void log(final LogLevel level, final String message) {
switch(level) {
case INFO:
this.plugin.getLogger().info(LogLevel.LOG_PREFIX + message);
return;
case ERROR:
this.plugin.getLogger().error(LogLevel.LOG_PREFIX + message);
}
}
@Override
public void log(final LogLevel level, final String message, final Throwable throwable) {
switch(level) {
case INFO:
this.plugin.getLogger().info(LogLevel.LOG_PREFIX + message, throwable);
return;
case ERROR:
this.plugin.getLogger().error(LogLevel.LOG_PREFIX + message, throwable);
for(String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) {
this.plugin.getLogger().error(LogLevel.LOG_PREFIX + line);
}
}
}
}
@@ -129,8 +129,8 @@ public class SpongeRootCommand implements CommandCallable, RootCommand {
}
BaseCommand regged = this.subCommands.get(key);
if (regged != null) {
ACFLog.severe("ACF Error: " + command.getName() + " registered subcommand " + key + " for root command " + this.name + " - but it is already defined in " + regged.getName());
ACFLog.severe("2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this.");
this.manager.log(LogLevel.ERROR, "ACF Error: " + command.getName() + " registered subcommand " + key + " for root command " + this.name + " - but it is already defined in " + regged.getName());
this.manager.log(LogLevel.ERROR, "2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this.");
return;
}
this.subCommands.put(key, command);