diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java b/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java index 65aab430..5c8b8038 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java @@ -2,6 +2,7 @@ package net.md_5.bungee.api.plugin; import java.io.File; import java.io.InputStream; +import java.util.logging.Logger; import lombok.Getter; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ConfigurationAdapter; @@ -19,6 +20,8 @@ public class Plugin private ProxyServer proxy; @Getter private File file; + @Getter + private Logger logger; /** * Called when the plugin has just been loaded. Most of the proxy will not @@ -78,5 +81,6 @@ public class Plugin this.proxy = proxy; this.description = description; this.file = file; + this.logger = new PluginLogger(this); } } diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginLogger.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginLogger.java new file mode 100644 index 00000000..d6a6ee31 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginLogger.java @@ -0,0 +1,25 @@ +package net.md_5.bungee.api.plugin; + +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import net.md_5.bungee.api.ProxyServer; + +public class PluginLogger extends Logger +{ + + private String pluginName; + + protected PluginLogger(Plugin plugin) + { + super( plugin.getClass().getCanonicalName(), null ); + pluginName = "[" + plugin.getDescription().getName() + "] "; + setParent( ProxyServer.getInstance().getLogger() ); + } + + @Override + public void log(LogRecord logRecord) + { + logRecord.setMessage( pluginName + logRecord.getMessage() ); + super.log( logRecord ); + } +}