All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.slf4j.impl.LogFactoryImpl Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
package org.slf4j.impl;

import com.firefly.utils.log.Log;
import com.firefly.utils.log.LogFactory;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class LogFactoryImpl implements ILoggerFactory {

    private Map map = new ConcurrentHashMap<>();

    @Override
    public Logger getLogger(String name) {
        Logger logger = map.get(name);
        if (logger != null) {
            return logger;
        } else {
            Log log = LogFactory.getInstance().getLog(name);
            if (log != null) {
                Logger newInstance = new LoggerImpl(log);
                Logger oldInstance = map.putIfAbsent(name, newInstance);
                return oldInstance == null ? newInstance : oldInstance;
            } else {
                return null;
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy