package de.nameless.gameEngine.util;
import java.util.Date;
import sun.management.StackTraceElementCompositeData;
import de.nameless.gameEngine.gui.NEConsole;
public class Logger {
private static Logger instance = new Logger();
private static final boolean DoDebug = true;
private static NEConsole console;
private Logger(){
console = new NEConsole();
console.setVisible(true);
}
private static Logger getInstance(){
if(instance == null) instance = new Logger();
return instance;
}
public static void log(String log){
String info = Thread.getAllStackTraces().get(Thread.currentThread())[4].getFileName();
info = info.substring(0, info.length()-5);
Logger.getInstance().wirte(info + ": \t" + log);
}
private static void log(String log, boolean time){
if(time) Logger.getInstance().wirte(new Date().toGMTString());
Logger.getInstance().wirte(log);
}
public static void debug(String log, boolean time){
String info = Thread.getAllStackTraces().get(Thread.currentThread())[4].getFileName();
info = info.substring(0, info.length()-5);
if(DoDebug){
log(info + ": \t" + log,time);
}
}
public void wirte(String s){
console.write(s);
}
}