Add option to disable colored logging (#382)
This commit is contained in:
parent
ad6e837aa5
commit
400f3a9156
@ -141,7 +141,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
scheduler = new LPBukkitScheduler(this);
|
scheduler = new LPBukkitScheduler(this);
|
||||||
localeManager = new NoopLocaleManager();
|
localeManager = new NoopLocaleManager();
|
||||||
senderFactory = new BukkitSenderFactory(this);
|
senderFactory = new BukkitSenderFactory(this);
|
||||||
log = new SenderLogger(getConsoleSender());
|
log = new SenderLogger(this, getConsoleSender());
|
||||||
|
|
||||||
DependencyManager.loadDependencies(this, Collections.singletonList(Dependency.CAFFEINE));
|
DependencyManager.loadDependencies(this, Collections.singletonList(Dependency.CAFFEINE));
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
scheduler = new LPBungeeScheduler(this);
|
scheduler = new LPBungeeScheduler(this);
|
||||||
localeManager = new NoopLocaleManager();
|
localeManager = new NoopLocaleManager();
|
||||||
senderFactory = new BungeeSenderFactory(this);
|
senderFactory = new BungeeSenderFactory(this);
|
||||||
log = new SenderLogger(getConsoleSender());
|
log = new SenderLogger(this, getConsoleSender());
|
||||||
|
|
||||||
DependencyManager.loadDependencies(this, Collections.singletonList(Dependency.CAFFEINE));
|
DependencyManager.loadDependencies(this, Collections.singletonList(Dependency.CAFFEINE));
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,11 @@ public class ConfigKeys {
|
|||||||
*/
|
*/
|
||||||
public static final ConfigKey<Boolean> USE_ARGUMENT_BASED_COMMAND_PERMISSIONS = BooleanKey.of("argument-based-command-permissions", false);
|
public static final ConfigKey<Boolean> USE_ARGUMENT_BASED_COMMAND_PERMISSIONS = BooleanKey.of("argument-based-command-permissions", false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the plugin should log messages to the console in color.
|
||||||
|
*/
|
||||||
|
public static final ConfigKey<Boolean> USE_COLORED_LOGGER = BooleanKey.of("colored-logger", true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If wildcards are being applied
|
* If wildcards are being applied
|
||||||
*/
|
*/
|
||||||
|
@ -30,24 +30,36 @@ import lombok.NonNull;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
import me.lucko.luckperms.api.Logger;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
import me.lucko.luckperms.common.locale.Message;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SenderLogger implements Logger {
|
public class SenderLogger implements Logger {
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
private final Sender console;
|
private final Sender console;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void info(@NonNull String s) {
|
public void info(@NonNull String s) {
|
||||||
Message.LOG_INFO.send(console, s);
|
msg(Message.LOG_INFO, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void warn(@NonNull String s) {
|
public void warn(@NonNull String s) {
|
||||||
Message.LOG_WARN.send(console, s);
|
msg(Message.LOG_WARN, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void severe(@NonNull String s) {
|
public void severe(@NonNull String s) {
|
||||||
Message.LOG_ERROR.send(console, s);
|
msg(Message.LOG_ERROR, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void msg(Message message, String s) {
|
||||||
|
String msg = message.asString(plugin.getLocaleManager(), s);
|
||||||
|
if (plugin.getConfiguration() != null && !plugin.getConfiguration().get(ConfigKeys.USE_COLORED_LOGGER)) {
|
||||||
|
msg = Util.stripColor(msg);
|
||||||
|
}
|
||||||
|
console.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
scheduler = new LPSpongeScheduler(this);
|
scheduler = new LPSpongeScheduler(this);
|
||||||
localeManager = new NoopLocaleManager();
|
localeManager = new NoopLocaleManager();
|
||||||
senderFactory = new SpongeSenderFactory(this);
|
senderFactory = new SpongeSenderFactory(this);
|
||||||
log = new SenderLogger(getConsoleSender());
|
log = new SenderLogger(this, getConsoleSender());
|
||||||
|
|
||||||
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
||||||
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
||||||
|
Loading…
Reference in New Issue
Block a user