src/Loggers/MonologLoggerFactory.php
/**
     * Creates a new logger instance based on the passed logger configuration.
     *
     * @param \TechDivision\Import\Configuration\ConfigurationInterface       $configuration       The system configuration
     * @param \TechDivision\Import\Configuration\LoggerConfigurationInterface $loggerConfiguration The logger configuration
     *
     * @return \Psr\Log\LoggerInterface The logger instance
     */
Creates a new logger instance based on the passed logger configuration.

@return \Psr\Log\LoggerInterface The logger instance
Creates a new logger instance based on the passed logger configuration . @return \ Psr \ Log \ LoggerInterface The logger instance
public function factory(
        ConfigurationInterface $configuration,
        LoggerConfigurationInterface $loggerConfiguration
    ) {
        $availableProcessors = $loggerConfiguration->getProcessors();
        $processors = array();
        foreach ($availableProcessors as $processorConfiguration) {
            $possibleProcessor = $this->getContainer()->get($processorConfiguration->getId());
            if ($possibleProcessor instanceof ProcessorFactoryInterface) {
                $processors[] = $possibleProcessor->factory($processorConfiguration);
            } else {
                $processors[] = $possibleProcessor;
            }
        }
        $availableHandlers = $loggerConfiguration->getHandlers();
        $handlers = array();
        foreach ($availableHandlers as $handlerConfiguration) {
            $handlers[] = $this->getMonologLoggerHandlerFactory()->factory($handlerConfiguration);
        }
        $loggerParams = array(
            ConfigurationKeys::NAME       => $loggerConfiguration->getChannelName(),
            ConfigurationKeys::HANDLERS   => $handlers,
            ConfigurationKeys::PROCESSORS => $processors
        );
        $loggerParams = array_merge($loggerParams, $loggerConfiguration->getParams());
        $reflectionClass = new \ReflectionClass(Logger::class);
        return $reflectionClass->newInstanceArgs(ConfigurationUtil::prepareConstructorArgs($reflectionClass, $loggerParams));
    }
public function factory ( ConfigurationInterface $ configuration , LoggerConfigurationInterface $ loggerConfiguration ) { $ availableProcessors = $ loggerConfiguration -> getProcessors ( ) ; $ processors = array ( ) ; foreach ( $ availableProcessors as $ processorConfiguration ) { $ possibleProcessor = $ this -> getContainer ( ) -> get ( $ processorConfiguration -> getId ( ) ) ; if ( $ possibleProcessor instanceof ProcessorFactoryInterface ) { $ processors [ ] = $ possibleProcessor -> factory ( $ processorConfiguration ) ; } else { $ processors [ ] = $ possibleProcessor ; } } $ availableHandlers = $ loggerConfiguration -> getHandlers ( ) ; $ handlers = array ( ) ; foreach ( $ availableHandlers as $ handlerConfiguration ) { $ handlers [ ] = $ this -> getMonologLoggerHandlerFactory ( ) -> factory ( $ handlerConfiguration ) ; } $ loggerParams = array ( ConfigurationKeys :: NAME => $ loggerConfiguration -> getChannelName ( ) , ConfigurationKeys :: HANDLERS => $ handlers , ConfigurationKeys :: PROCESSORS => $ processors ) ; $ loggerParams = array_merge ( $ loggerParams , $ loggerConfiguration -> getParams ( ) ) ; $ reflectionClass = new \ ReflectionClass ( Logger :: class ) ; return $ reflectionClass -> newInstanceArgs ( ConfigurationUtil :: prepareConstructorArgs ( $ reflectionClass , $ loggerParams ) ) ; }
Creates a new logger instance based on the passed logger configuration.
Creates a new logger instance based on the passed logger configuration .
// load the available processors from the configuration // initialize the processors /** @var \TechDivision\Import\Configuration\Logger\ProcessorConfigurationInterface $processorConfiguration */ // create the processor (factory) instance // query whether or not we've a factory or the instance // load the available handlers from the configuration // initialize the handlers /** @var \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface $handlerConfiguration */ // prepare the logger params // append the params from the logger configuration // initialize the Monolog Logger instance itself