60 lines
1.2 KiB
Java
Raw Normal View History

2014-10-09 12:01:16 +02:00
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;
}
}