src/Jackiedo/LogReader/LogReader.php
protected function parseLog($content, $allowedEnvironment = null, $allowedLevel = [])
    {
        $log = [];

        $parsed = $this->parser->parseLogContent($content);

        extract($parsed, EXTR_PREFIX_ALL, 'parsed');

        if (empty($parsed_headerSet)) {
            return $log;
        }

        $needReFormat = in_array('Next', $parsed_headerSet);
        $newContent   = null;

        foreach ($parsed_headerSet as $key => $header) {
            if (empty($parsed_dateSet[$key])) {
                $parsed_dateSet[$key]  = $parsed_dateSet[$key-1];
                $parsed_envSet[$key]   = $parsed_envSet[$key-1];
                $parsed_levelSet[$key] = $parsed_levelSet[$key-1];
                $header                = str_replace("Next", $parsed_headerSet[$key-1], $header);
            }

            $newContent .= $header.' '.$parsed_bodySet[$key];

            if ((empty($allowedEnvironment) || $allowedEnvironment == $parsed_envSet[$key]) && $this->levelable->filter($parsed_levelSet[$key], $allowedLevel)) {
                $log[] = [
                    'environment' => $parsed_envSet[$key],
                    'level'       => $parsed_levelSet[$key],
                    'date'        => $parsed_dateSet[$key],
                    'file_path'   => $this->getCurrentLogPath(),
                    'header'      => $header,
                    'body'        => $parsed_bodySet[$key]
                ];
            }
        }

        if ($needReFormat) {
            file_put_contents($this->getCurrentLogPath(), $newContent);
        }

        return $log;
    }
protected function parseLog($content, $allowedEnvironment = null, $allowedLevel = [])
    {
        $log = [];

        $parsed = $this->parser->parseLogContent($content);

        extract($parsed, EXTR_PREFIX_ALL, 'parsed');

        if (empty($parsed_headerSet)) {
            return $log;
        }

        $needReFormat = in_array('Next', $parsed_headerSet);
        $newContent   = null;

        foreach ($parsed_headerSet as $key => $header) {
            if (empty($parsed_dateSet[$key])) {
                $parsed_dateSet[$key]  = $parsed_dateSet[$key-1];
                $parsed_envSet[$key]   = $parsed_envSet[$key-1];
                $parsed_levelSet[$key] = $parsed_levelSet[$key-1];
                $header                = str_replace("Next", $parsed_headerSet[$key-1], $header);
            }

            $newContent .= $header.' '.$parsed_bodySet[$key];

            if ((empty($allowedEnvironment) || $allowedEnvironment == $parsed_envSet[$key]) && $this->levelable->filter($parsed_levelSet[$key], $allowedLevel)) {
                $log[] = [
                    'environment' => $parsed_envSet[$key],
                    'level'       => $parsed_levelSet[$key],
                    'date'        => $parsed_dateSet[$key],
                    'file_path'   => $this->getCurrentLogPath(),
                    'header'      => $header,
                    'body'        => $parsed_bodySet[$key]
                ];
            }
        }

        if ($needReFormat) {
            file_put_contents($this->getCurrentLogPath(), $newContent);
        }

        return $log;
    }
protected function parseLog ( $ content , $ allowedEnvironment = null , $ allowedLevel = [ ] ) { $ log = [ ] ; $ parsed = $ this -> parser -> parseLogContent ( $ content ) ; extract ( $ parsed , EXTR_PREFIX_ALL , 'parsed' ) ; if ( empty ( $ parsed_headerSet ) ) { return $ log ; } $ needReFormat = in_array ( 'Next' , $ parsed_headerSet ) ; $ newContent = null ; foreach ( $ parsed_headerSet as $ key => $ header ) { if ( empty ( $ parsed_dateSet [ $ key ] ) ) { $ parsed_dateSet [ $ key ] = $ parsed_dateSet [ $ key - 1 ] ; $ parsed_envSet [ $ key ] = $ parsed_envSet [ $ key - 1 ] ; $ parsed_levelSet [ $ key ] = $ parsed_levelSet [ $ key - 1 ] ; $ header = str_replace ( "Next" , $ parsed_headerSet [ $ key - 1 ] , $ header ) ; } $ newContent .= $ header . ' ' . $ parsed_bodySet [ $ key ] ; if ( ( empty ( $ allowedEnvironment ) || $ allowedEnvironment == $ parsed_envSet [ $ key ] ) && $ this -> levelable -> filter ( $ parsed_levelSet [ $ key ] , $ allowedLevel ) ) { $ log [ ] = [ 'environment' => $ parsed_envSet [ $ key ] , 'level' => $ parsed_levelSet [ $ key ] , 'date' => $ parsed_dateSet [ $ key ] , 'file_path' => $ this -> getCurrentLogPath ( ) , 'header' => $ header , 'body' => $ parsed_bodySet [ $ key ] ] ; } } if ( $ needReFormat ) { file_put_contents ( $ this -> getCurrentLogPath ( ) , $ newContent ) ; } return $ log ; }
Parses the content of the file separating the errors into a single array.

@param  string  $content
@param  string  $allowedEnvironment
@param  array   $allowedLevel

@return array
Parses the content of the file separating the errors into a single array .