public function resolve($logFormat)
    {
        // Loop over connectionMap and see if the log format matches any of them
        foreach ($this->connectionMap as $connection => $match) {
            // Because the last connection stream is an effective catch all i.e. just specifying a
            // path to a file, lets make sure the user wasn't trying to use another handler but got
            // the format wrong. If they did then show them the correct format
            if ($connection == 'Stream' and stripos($logFormat, 'stream') !== 0) {
                $pattern = '~^(?P<handler>'.implode('|', array_keys($this->connectionMap)).')(.*)$~i';

                if ($possible = $this->matches($pattern, $logFormat)) {
                    // Map to correct key case
                    $handler = str_replace(
                        array_map('strtolower', array_keys($this->connectionMap)),
                        array_keys($this->connectionMap),
                        strtolower($possible['handler'])
                    );

                    // Tell them the error of their ways
                    $format = str_replace(array('(?:', ')?', '\)'), '', $this->connectionMap[$handler]);

                    $cb = function ($m) {
                        return ($m[1] == 'ignore') ? '' : '<'.$m[1].'>';
                    };
                    $format = preg_replace_callback('/\(\?P<([a-z_]+)>(?:.+?)\)/', $cb, $format);

                    throw new \InvalidArgumentException('Invalid format "'.$logFormat.'" for "'.$handler.'" handler. Should be of format "'.$format.'"');
                }
            }

            if ($args = $this->matches('~^'.$match.'$~i', $logFormat)) {
                $connectorClass = new \ReflectionClass('Resque\Logger\Handler\Connector\\'.$connection.'Connector');
                $connectorClass = $connectorClass->newInstance();

                $handler = $connectorClass->resolve($this->command, $this->input, $this->output, $args);
                $handler->pushProcessor($connectorClass->processor($this->command, $this->input, $this->output, $args));

                return $handler;
            }
        }

        throw new \InvalidArgumentException('Log format "'.$logFormat.'" is invalid');
    }
public function resolve($logFormat)
    {
        // Loop over connectionMap and see if the log format matches any of them
        foreach ($this->connectionMap as $connection => $match) {
            // Because the last connection stream is an effective catch all i.e. just specifying a
            // path to a file, lets make sure the user wasn't trying to use another handler but got
            // the format wrong. If they did then show them the correct format
            if ($connection == 'Stream' and stripos($logFormat, 'stream') !== 0) {
                $pattern = '~^(?P<handler>'.implode('|', array_keys($this->connectionMap)).')(.*)$~i';

                if ($possible = $this->matches($pattern, $logFormat)) {
                    // Map to correct key case
                    $handler = str_replace(
                        array_map('strtolower', array_keys($this->connectionMap)),
                        array_keys($this->connectionMap),
                        strtolower($possible['handler'])
                    );

                    // Tell them the error of their ways
                    $format = str_replace(array('(?:', ')?', '\)'), '', $this->connectionMap[$handler]);

                    $cb = function ($m) {
                        return ($m[1] == 'ignore') ? '' : '<'.$m[1].'>';
                    };
                    $format = preg_replace_callback('/\(\?P<([a-z_]+)>(?:.+?)\)/', $cb, $format);

                    throw new \InvalidArgumentException('Invalid format "'.$logFormat.'" for "'.$handler.'" handler. Should be of format "'.$format.'"');
                }
            }

            if ($args = $this->matches('~^'.$match.'$~i', $logFormat)) {
                $connectorClass = new \ReflectionClass('Resque\Logger\Handler\Connector\\'.$connection.'Connector');
                $connectorClass = $connectorClass->newInstance();

                $handler = $connectorClass->resolve($this->command, $this->input, $this->output, $args);
                $handler->pushProcessor($connectorClass->processor($this->command, $this->input, $this->output, $args));

                return $handler;
            }
        }

        throw new \InvalidArgumentException('Log format "'.$logFormat.'" is invalid');
    }
public function resolve ( $ logFormat ) { // Loop over connectionMap and see if the log format matches any of them foreach ( $ this -> connectionMap as $ connection => $ match ) { // Because the last connection stream is an effective catch all i.e. just specifying a // path to a file, lets make sure the user wasn't trying to use another handler but got // the format wrong. If they did then show them the correct format if ( $ connection == 'Stream' and stripos ( $ logFormat , 'stream' ) !== 0 ) { $ pattern = '~^(?P<handler>' . implode ( '|' , array_keys ( $ this -> connectionMap ) ) . ')(.*)$~i' ; if ( $ possible = $ this -> matches ( $ pattern , $ logFormat ) ) { // Map to correct key case $ handler = str_replace ( array_map ( 'strtolower' , array_keys ( $ this -> connectionMap ) ) , array_keys ( $ this -> connectionMap ) , strtolower ( $ possible [ 'handler' ] ) ) ; // Tell them the error of their ways $ format = str_replace ( array ( '(?:' , ')?' , '\)' ) , '' , $ this -> connectionMap [ $ handler ] ) ; $ cb = function ( $ m ) { return ( $ m [ 1 ] == 'ignore' ) ? '' : '<' . $ m [ 1 ] . '>' ; } ; $ format = preg_replace_callback ( '/\(\?P<([a-z_]+)>(?:.+?)\)/' , $ cb , $ format ) ; throw new \ InvalidArgumentException ( 'Invalid format "' . $ logFormat . '" for "' . $ handler . '" handler. Should be of format "' . $ format . '"' ) ; } } if ( $ args = $ this -> matches ( '~^' . $ match . '$~i' , $ logFormat ) ) { $ connectorClass = new \ ReflectionClass ( 'Resque\Logger\Handler\Connector\\' . $ connection . 'Connector' ) ; $ connectorClass = $ connectorClass -> newInstance ( ) ; $ handler = $ connectorClass -> resolve ( $ this -> command , $ this -> input , $ this -> output , $ args ) ; $ handler -> pushProcessor ( $ connectorClass -> processor ( $ this -> command , $ this -> input , $ this -> output , $ args ) ) ; return $ handler ; } } throw new \ InvalidArgumentException ( 'Log format "' . $ logFormat . '" is invalid' ) ; }
Resolves a Monolog handler from string input

@param  mixed                            $logFormat
@throws InvalidArgumentException
@return Monolog\Handler\HandlerInterface
Resolves a Monolog handler from string input