use of de.Keyle.MyPet.api.util.LogFormat in project MyPet by xXKeyleXx.
the class MyPetLogger method setupDebugLogger.
protected boolean setupDebugLogger() {
if (getHandlers().length > 0) {
for (Handler h : getHandlers()) {
if (h.toString().equals("MyPet-Debug-Logger-FileHandler")) {
if (Configuration.Log.LEVEL.equalsIgnoreCase("OFF")) {
removeHandler(h);
h.close();
return false;
}
debugLogFileHandler = (FileHandler) h;
return true;
}
}
}
if (Configuration.Log.LEVEL.equalsIgnoreCase("OFF")) {
return false;
}
if (debugLogFileHandler != null) {
addHandler(debugLogFileHandler);
return true;
}
try {
File logsFolder = new File(MyPetApi.getPlugin().getDataFolder(), "logs");
logsFolder.mkdirs();
File logFile = new File(logsFolder, File.separator + "MyPet.log");
FileHandler fileHandler = new FileHandler(logFile.getAbsolutePath(), true) {
@Override
public String toString() {
return "MyPet-Debug-Logger-FileHandler";
}
};
Level level;
try {
level = Level.parse(Configuration.Log.LEVEL);
} catch (IllegalArgumentException e) {
level = Level.OFF;
this.warning(e.getMessage());
}
fileHandler.setLevel(level);
System.out.println("Level: " + level);
fileHandler.setFormatter(new LogFormat());
addHandler(fileHandler);
debugLogFileHandler = fileHandler;
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
Aggregations