package de.ctdo.crashtest.log;

import java.util.ArrayList;
import java.util.List;

public class Logger {
    private final static Logger instance = new Logger();
    private final List<ILogger> loggerList = new ArrayList<ILogger>();


    public void addLogger(ILogger listener) {
        loggerList.add(listener);
    }

    private Logger() {
    
    }

    public static Logger getInstance() {
        return instance;
    }
    
    private void log(String message) {

        System.out.println("LOG: " + message);

        for(ILogger logger: loggerList) {
            synchronized (this) {
                logger.log(message);
            }
        }

    }
    
    public static void sLog(String message) {
        getInstance().log(message);
    }
}
