forked from JavaTX/JavaCompilerCore
60 lines
1.2 KiB
Java
60 lines
1.2 KiB
Java
|
package de.dhbwstuttgart.logger;
|
|||
|
|
|||
|
import java.io.PrintStream;
|
|||
|
import java.util.HashMap;
|
|||
|
|
|||
|
public class Logger {
|
|||
|
|
|||
|
private static PrintStream standardOutput;
|
|||
|
private static final HashMap<String, Logger> LOGGER_DIRECTORY = new HashMap<>();
|
|||
|
|
|||
|
private String name;
|
|||
|
private PrintStream output;
|
|||
|
|
|||
|
private Logger(String name, PrintStream output) {
|
|||
|
this.name = name;
|
|||
|
this.output = output;
|
|||
|
}
|
|||
|
|
|||
|
public void debug(String message){
|
|||
|
output(message);
|
|||
|
}
|
|||
|
|
|||
|
public static Logger getLogger(String name) {
|
|||
|
Logger ret;
|
|||
|
if(LOGGER_DIRECTORY.containsKey(name)){
|
|||
|
ret = LOGGER_DIRECTORY.get(name);
|
|||
|
}else{
|
|||
|
ret = new Logger(name, standardOutput);
|
|||
|
LOGGER_DIRECTORY.put(name, ret);
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
|
|||
|
private void output(String msg){
|
|||
|
if(output != null){
|
|||
|
output.println(msg);
|
|||
|
}else if(standardOutput != null){
|
|||
|
standardOutput.println(msg);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void info(String string) {
|
|||
|
// TODO Auto-generated method stub
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void error(String string) {
|
|||
|
// TODO Auto-generated method stub
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* wird hier null <EFBFBD>bergeben, so wird s<EFBFBD>mtliches Logging unterdr<EFBFBD>ckt.
|
|||
|
*/
|
|||
|
public static void setStandardOutput(PrintStream outputStream) {
|
|||
|
Logger.standardOutput = outputStream;
|
|||
|
}
|
|||
|
|
|||
|
}
|