import importlib


def create(configs, logger):
    """Initializes the Diagnotic Logger instances based on the
    provided JSON configuration(s). The expected keys are:

    Package: A package name containing the diagnostic logger
        module. It should be in python path of the environment.
    Type: A first-level type for the Logger, which should correspond
        the name of the module containing the Logger implementation.
    SubType: The exact implementation of the sniffer, which should
        correspond to the name of the class to be used.
    HostLogPath: This is the default directory used to dump any logs
        that are captured or any other files that are stored as part
        of the logging process. It's use is implementation specific,
        but it should be provided by all loggers for completeness.
    Configs: A dictionary specifying baseline configurations of the
        particular Logger. These configurations may be overridden at
        the start of a session.
    """
    objs = []
    for c in configs:
        diag_package_name = c["Package"]  # package containing module
        diag_logger_type = c["Type"]  # module name
        diag_logger_name = c["SubType"]  # class name
        host_log_path = c["HostLogPath"]
        base_configs = c["Configs"]
        module_name = "{}.{}".format(diag_package_name, diag_logger_type)
        module = importlib.import_module(module_name)
        logger = getattr(module, diag_logger_name)

        objs.append(logger(host_log_path,
                           logger,
                           config_container=base_configs))
    return objs