Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
PluginLogger.java
Go to the documentation of this file.
1 package org.bukkit.plugin;
2 
3 import java.util.logging.Level;
4 import java.util.logging.LogRecord;
5 import java.util.logging.Logger;
6 
13 public class PluginLogger extends Logger {
14  private String pluginName;
15 
20  public PluginLogger(Plugin context) {
21  super(context.getClass().getCanonicalName(), null);
22  String prefix = context.getDescription().getPrefix();
23  pluginName = prefix != null ? new StringBuilder().append("[").append(prefix).append("] ").toString() : "[" + context.getDescription().getName() + "] ";
24  setParent(context.getServer().getLogger());
25  setLevel(Level.ALL);
26  }
27 
28  @Override
29  public void log(LogRecord logRecord) {
30  logRecord.setMessage(pluginName + logRecord.getMessage());
31  super.log(logRecord);
32  }
33 
34 }