package org.apache.logging.log4j.core.config;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;

@Plugin(
   name = "loggers",
   category = "Core"
)
public final class LoggersPlugin {
   private LoggersPlugin() {
   }

   @PluginFactory
   public static Loggers createLoggers(@PluginElement("Loggers") LoggerConfig[] loggers) {
      ConcurrentMap<String, LoggerConfig> loggerMap = new ConcurrentHashMap();
      LoggerConfig root = null;
      LoggerConfig[] arr$ = loggers;
      int len$ = loggers.length;

      for(int i$ = 0; i$ < len$; ++i$) {
         LoggerConfig logger = arr$[i$];
         if (logger != null) {
            if (logger.getName().isEmpty()) {
               root = logger;
            }

            loggerMap.put(logger.getName(), logger);
         }
      }

      return new Loggers(loggerMap, root);
   }
}
