src/Jackiedo/LogReader/LogParser.php
public function parseLogContent($content)
    {
        $headerSet = $dateSet = $envSet = $levelSet = $bodySet = [];

        $pattern = "/^" .self::LOG_DATE_PATTERN. "\s" .self::LOG_ENVIRONMENT_PATTERN. "\." .self::LOG_LEVEL_PATTERN. "\:|Next/m";

        preg_match_all($pattern, $content, $matchs);

        if (is_array($matchs)) {
            $bodySet = array_map('ltrim', preg_split($pattern, $content));

            if (empty($bodySet[0]) && count($bodySet) > count($matchs[0])) {
                array_shift($bodySet);
            }

            $headerSet = $matchs[0];
            $dateSet   = $matchs[1];
            $envSet    = $matchs[2];
            $levelSet  = $matchs[3];
            $bodySet   = $bodySet;
        }

        return compact('headerSet', 'dateSet', 'envSet', 'levelSet', 'bodySet');
    }
public function parseLogContent($content)
    {
        $headerSet = $dateSet = $envSet = $levelSet = $bodySet = [];

        $pattern = "/^" .self::LOG_DATE_PATTERN. "\s" .self::LOG_ENVIRONMENT_PATTERN. "\." .self::LOG_LEVEL_PATTERN. "\:|Next/m";

        preg_match_all($pattern, $content, $matchs);

        if (is_array($matchs)) {
            $bodySet = array_map('ltrim', preg_split($pattern, $content));

            if (empty($bodySet[0]) && count($bodySet) > count($matchs[0])) {
                array_shift($bodySet);
            }

            $headerSet = $matchs[0];
            $dateSet   = $matchs[1];
            $envSet    = $matchs[2];
            $levelSet  = $matchs[3];
            $bodySet   = $bodySet;
        }

        return compact('headerSet', 'dateSet', 'envSet', 'levelSet', 'bodySet');
    }
public function parseLogContent ( $ content ) { $ headerSet = $ dateSet = $ envSet = $ levelSet = $ bodySet = [ ] ; $ pattern = "/^" . self :: LOG_DATE_PATTERN . "\s" . self :: LOG_ENVIRONMENT_PATTERN . "\." . self :: LOG_LEVEL_PATTERN . "\:|Next/m" ; preg_match_all ( $ pattern , $ content , $ matchs ) ; if ( is_array ( $ matchs ) ) { $ bodySet = array_map ( 'ltrim' , preg_split ( $ pattern , $ content ) ) ; if ( empty ( $ bodySet [ 0 ] ) && count ( $ bodySet ) > count ( $ matchs [ 0 ] ) ) { array_shift ( $ bodySet ) ; } $ headerSet = $ matchs [ 0 ] ; $ dateSet = $ matchs [ 1 ] ; $ envSet = $ matchs [ 2 ] ; $ levelSet = $ matchs [ 3 ] ; $ bodySet = $ bodySet ; } return compact ( 'headerSet' , 'dateSet' , 'envSet' , 'levelSet' , 'bodySet' ) ; }
Parses content of the log file into an array containing the necessary information

@param  string  $content

@return array   Structure is ['headerSet' => [], 'dateSet' => [], 'envSet' => [], 'levelSet' => [], 'bodySet' => []]
Parses content of the log file into an array containing the necessary information