src/Loggers/StreamHandlerFactory.php
/**
     * Creates a new formatter instance based on the passed configuration.
     *
     * @param \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface $handlerConfiguration The handler configuration
     *
     * @return \Monolog\Handler\HandlerInterface The handler instance
     */
Creates a new formatter instance based on the passed configuration.

@return \Monolog\Handler\HandlerInterface The handler instance
Creates a new formatter instance based on the passed configuration . @return \ Monolog \ Handler \ HandlerInterface The handler instance
public function factory(HandlerConfigurationInterface $handlerConfiguration)
    {
        $status = array();
        if ($this->registryProcessor->hasAttribute(CacheKeys::STATUS)) {
            $status = $this->registryProcessor->getAttribute(CacheKeys::STATUS);
        }
        if (isset($status[RegistryKeys::TARGET_DIRECTORY])) {
            $this->targetDirectory = $status[RegistryKeys::TARGET_DIRECTORY];
        }
        $stream = $handlerConfiguration->getParam(ConfigurationKeys::STREAM);
        if ($handlerConfiguration->hasParam(ConfigurationKeys::RELATIVE) ? $handlerConfiguration->getParam(ConfigurationKeys::RELATIVE) : true) {
            $stream = implode(DIRECTORY_SEPARATOR, array($this->targetDirectory, $stream));
        }
        $params = array_replace($handlerConfiguration->getParams(), array(ConfigurationKeys::STREAM => $stream));
        if ($this->logLevel) {
            $params[ConfigurationKeys::LEVEL] = $this->logLevel;
        }
        if ($this->stream && is_file($this->stream) && $this->stream !== $stream) {
            rename($this->stream, $stream);
        }
        $this->stream = $stream;
        if (isset($status[RegistryKeys::FILES])) {
            $status = array_merge_recursive(
                $status,
                array(
                    RegistryKeys::FILES => array(
                        $this->stream => array(
                            Uuid::uuid4()->toString() => array(
                                RegistryKeys::STATUS => 1,
                                RegistryKeys::SKIPPED_ROWS => 0,
                                RegistryKeys::PROCESSED_ROWS => 0
                            )
                        )
                    )
                )
            );
            $this->registryProcessor->mergeAttributesRecursive(CacheKeys::STATUS, $status);
        }
        $reflectionClass = new \ReflectionClass(StreamHandler::class);
        return $reflectionClass->newInstanceArgs(ConfigurationUtil::prepareConstructorArgs($reflectionClass, $params));
    }
public function factory ( HandlerConfigurationInterface $ handlerConfiguration ) { $ status = array ( ) ; if ( $ this -> registryProcessor -> hasAttribute ( CacheKeys :: STATUS ) ) { $ status = $ this -> registryProcessor -> getAttribute ( CacheKeys :: STATUS ) ; } if ( isset ( $ status [ RegistryKeys :: TARGET_DIRECTORY ] ) ) { $ this -> targetDirectory = $ status [ RegistryKeys :: TARGET_DIRECTORY ] ; } $ stream = $ handlerConfiguration -> getParam ( ConfigurationKeys :: STREAM ) ; if ( $ handlerConfiguration -> hasParam ( ConfigurationKeys :: RELATIVE ) ? $ handlerConfiguration -> getParam ( ConfigurationKeys :: RELATIVE ) : true ) { $ stream = implode ( DIRECTORY_SEPARATOR , array ( $ this -> targetDirectory , $ stream ) ) ; } $ params = array_replace ( $ handlerConfiguration -> getParams ( ) , array ( ConfigurationKeys :: STREAM => $ stream ) ) ; if ( $ this -> logLevel ) { $ params [ ConfigurationKeys :: LEVEL ] = $ this -> logLevel ; } if ( $ this -> stream && is_file ( $ this -> stream ) && $ this -> stream !== $ stream ) { rename ( $ this -> stream , $ stream ) ; } $ this -> stream = $ stream ; if ( isset ( $ status [ RegistryKeys :: FILES ] ) ) { $ status = array_merge_recursive ( $ status , array ( RegistryKeys :: FILES => array ( $ this -> stream => array ( Uuid :: uuid4 ( ) -> toString ( ) => array ( RegistryKeys :: STATUS => 1 , RegistryKeys :: SKIPPED_ROWS => 0 , RegistryKeys :: PROCESSED_ROWS => 0 ) ) ) ) ) ; $ this -> registryProcessor -> mergeAttributesRecursive ( CacheKeys :: STATUS , $ status ) ; } $ reflectionClass = new \ ReflectionClass ( StreamHandler :: class ) ; return $ reflectionClass -> newInstanceArgs ( ConfigurationUtil :: prepareConstructorArgs ( $ reflectionClass , $ params ) ) ; }
Creates a new formatter instance based on the passed configuration.
Creates a new formatter instance based on the passed configuration .
// initialize the status array // try to load the actual import status from the registry processor // query whether or not the target directory has been changed // query whether or not the given log file is relative to the target // directory (for backwards compatility the default value must be YES) // override the filename in the params // override the log level, if specified in // the configuration or as CLI option // query wehther or not the log filename has been changed, if yes rename it // set the new log filename // we've to query whether or not the status has been initialized // if yes, merge the log filename into the status // add the logger to the import artefacts // create and return the handler instance