mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 03:05:49 +01:00
Add per plugin loggers
This commit is contained in:
parent
0afefa8f61
commit
aefe3333a9
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user