package de.dhbwstuttgart.logger; import java.io.PrintStream; import java.util.HashMap; public class Logger { private static PrintStream standardOutput; private static final HashMap 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 übergeben, so wird sämtliches Logging unterdrückt. */ public static void setStandardOutput(PrintStream outputStream) { Logger.standardOutput = outputStream; } }