Make logging messages a bit less obnoxious

* Removed the ascii text from the startup output
* Log messages (but not command output) is now sent through the standard server logger, and isn't colored
This commit is contained in:
Luck
2018-06-16 16:59:59 +01:00
Unverified
parent 6baa472567
commit b8c06904ab
23 changed files with 275 additions and 160 deletions
@@ -180,11 +180,6 @@ public final class ConfigKeys {
*/
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
*/
@@ -59,6 +59,13 @@ public enum Dependency {
"mmz3ltQbS8xXGA2scM0ZH6raISlt4nukjCiU2l9Jxfs="
),
TEXT(
"net{}kyori",
"text",
"1.11-1.4.0",
"drQpwf+oI1+DPrn0iCvEtoID+xXR3dpZK5ySaBrUiok=",
Relocation.of("text", "net{}kyori{}text")
),
CAFFEINE(
"com{}github{}ben-manes{}caffeine",
"caffeine",
@@ -60,9 +60,6 @@ public enum Message {
/*
* Logging
*/
LOG_INFO("&7&l[&bL&3P&7&l] &3{}", false),
LOG_WARN("&7&l[&bLuck&3Perms&7&l] &c[WARN] {}", false),
LOG_ERROR("&7&l[&bLuck&3Perms&7&l] &4[ERROR] {}", false),
LOG(
"{PREFIX}&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)" + "\n" +
"{PREFIX}&3LOG &3&l> &f{}",
@@ -46,7 +46,7 @@ import me.lucko.luckperms.common.inheritance.InheritanceHandler;
import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.messaging.InternalMessagingService;
import me.lucko.luckperms.common.messaging.MessagingFactory;
import me.lucko.luckperms.common.plugin.util.PluginLogger;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.StorageFactory;
@@ -64,7 +64,6 @@ import java.util.concurrent.TimeUnit;
public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
// init during load
private PluginLogger logger;
private DependencyManager dependencyManager;
// init during enable
@@ -86,13 +85,12 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
* Performs the initial actions to load the plugin
*/
public final void load() {
// load the sender factory instance and create a new logger for the plugin
setupSenderFactory();
this.logger = new PluginLogger(this, getConsoleSender());
// load dependencies
this.dependencyManager = new DependencyManager(this);
this.dependencyManager.loadDependencies(getGlobalDependencies());
// load the sender factory instance
setupSenderFactory();
}
public final void enable() {
@@ -237,6 +235,11 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
protected void removePlatformHooks() {}
@Override
public PluginLogger getLogger() {
return getBootstrap().getPluginLogger();
}
@Override
public void setMessagingService(InternalMessagingService messagingService) {
if (this.messagingService == null) {
@@ -244,11 +247,6 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
}
}
@Override
public PluginLogger getLogger() {
return this.logger;
}
@Override
public DependencyManager getDependencyManager() {
return this.dependencyManager;
@@ -320,12 +318,9 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
}
private void displayBanner(Sender sender) {
sender.sendMessage(MessageUtils.color("&b __ &3 __ ___ __ __ "));
sender.sendMessage(MessageUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
sender.sendMessage(MessageUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
sender.sendMessage(MessageUtils.color(" "));
sender.sendMessage(MessageUtils.color("&2 Loading version &bv" + getBootstrap().getVersion() + "&2 on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand()));
sender.sendMessage(MessageUtils.color("&8 Running on server version " + getBootstrap().getServerVersion()));
sender.sendMessage(MessageUtils.color(" "));
sender.sendMessage(MessageUtils.color("&b &3 __ "));
sender.sendMessage(MessageUtils.color("&b | &3|__) " + "&2LuckPerms &bv" + getBootstrap().getVersion()));
sender.sendMessage(MessageUtils.color("&b |___ &3| " + "&8running on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand()));
sender.sendMessage("");
}
}
@@ -44,8 +44,8 @@ import me.lucko.luckperms.common.managers.user.UserManager;
import me.lucko.luckperms.common.messaging.InternalMessagingService;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
import me.lucko.luckperms.common.plugin.util.PluginLogger;
import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.dao.file.FileWatcher;
@@ -27,6 +27,7 @@ package me.lucko.luckperms.common.plugin.bootstrap;
import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
import java.io.InputStream;
@@ -48,6 +49,13 @@ import javax.annotation.Nullable;
*/
public interface LuckPermsBootstrap {
/**
* Gets the plugin logger
*
* @return the logger
*/
PluginLogger getPluginLogger();
/**
* Gets an adapter for the platforms scheduler
*
@@ -0,0 +1,51 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.plugin.logging;
import java.util.logging.Logger;
public class JavaPluginLogger implements PluginLogger {
private final Logger logger;
public JavaPluginLogger(Logger logger) {
this.logger = logger;
}
@Override
public void info(String s) {
this.logger.info(s);
}
@Override
public void warn(String s) {
this.logger.warning(s);
}
@Override
public void severe(String s) {
this.logger.severe(s);
}
}
@@ -23,15 +23,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.plugin.util;
import me.lucko.luckperms.common.command.utils.MessageUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.locale.message.Message;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.sender.Sender;
import java.util.Objects;
package me.lucko.luckperms.common.plugin.logging;
/**
* Represents the logger instance being used by LuckPerms on the platform.
@@ -39,32 +31,10 @@ import java.util.Objects;
* <p>Messages sent using the logger are sent prefixed with the LuckPerms tag,
* and on some implementations will be colored depending on the message type.</p>
*/
public class PluginLogger {
private final LuckPermsPlugin plugin;
private final Sender console;
public interface PluginLogger {
public PluginLogger(LuckPermsPlugin plugin, Sender console) {
this.plugin = plugin;
this.console = console;
}
void info(String s);
void warn(String s);
void severe(String s);
public void info(String s) {
msg(Message.LOG_INFO, Objects.requireNonNull(s));
}
public void warn(String s) {
msg(Message.LOG_WARN, Objects.requireNonNull(s));
}
public void severe(String s) {
msg(Message.LOG_ERROR, Objects.requireNonNull(s));
}
private void msg(Message message, String s) {
String msg = message.asString(this.plugin.getLocaleManager(), s);
if (this.plugin.getConfiguration() != null && !this.plugin.getConfiguration().get(ConfigKeys.USE_COLORED_LOGGER)) {
msg = MessageUtils.stripColor(msg);
}
this.console.sendMessage(msg);
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.plugin.logging;
import org.slf4j.Logger;
public class Slf4jPluginLogger implements PluginLogger {
private final Logger logger;
public Slf4jPluginLogger(Logger logger) {
this.logger = logger;
}
@Override
public void info(String s) {
this.logger.info(s);
}
@Override
public void warn(String s) {
this.logger.warn(s);
}
@Override
public void severe(String s) {
this.logger.error(s);
}
}