src/Debugger/ChromeLogger.php
protected function createEntryData(array $entry): array
    {
        // NOTE: "log" level type is deliberately omitted from the following map, since
        //       it's the default entry-type in ChromeLogger, and can be omitted.

        static $LEVELS = [
            LogLevel::DEBUG => self::LOG,
            LogLevel::INFO => self::INFO,
            LogLevel::NOTICE => self::INFO,
            LogLevel::WARNING => self::WARN,
            LogLevel::ERROR => self::ERROR,
            LogLevel::CRITICAL => self::ERROR,
            LogLevel::ALERT => self::ERROR,
            LogLevel::EMERGENCY => self::ERROR,
        ];

        $row = [];

        [$level, $message, $context] = $entry;

        $data = [
            \str_replace('%', '%%', Dumper::interpolate($message, $context)),
        ];

        if (\count($context)) {
            $context = $this->sanitize($context);

            $data = \array_merge($data, $context);
        }

        $row[] = $data;

        $row[] = $LEVELS[$level] ?? self::LOG;

        if (isset($context['exception'])) {
            // NOTE: per PSR-3, this reserved key could be anything, but if it is an Exception, we
            //       can use that Exception to obtain a stack-trace for output in ChromeLogger.
            $exception = $context['exception'];

            if ($exception instanceof \Throwable) {
                $row[] = $exception->__toString();
            }
        }

        // Optimization: ChromeLogger defaults to "log" if no entry-type is specified.
        if ($row[1] === self::LOG) {
            if (\count($row) === 2) {
                unset($row[1]);
            } else {
                $row[1] = '';
            }
        }

        return $row;
    }
protected function createEntryData(array $entry): array
    {
        // NOTE: "log" level type is deliberately omitted from the following map, since
        //       it's the default entry-type in ChromeLogger, and can be omitted.

        static $LEVELS = [
            LogLevel::DEBUG => self::LOG,
            LogLevel::INFO => self::INFO,
            LogLevel::NOTICE => self::INFO,
            LogLevel::WARNING => self::WARN,
            LogLevel::ERROR => self::ERROR,
            LogLevel::CRITICAL => self::ERROR,
            LogLevel::ALERT => self::ERROR,
            LogLevel::EMERGENCY => self::ERROR,
        ];

        $row = [];

        [$level, $message, $context] = $entry;

        $data = [
            \str_replace('%', '%%', Dumper::interpolate($message, $context)),
        ];

        if (\count($context)) {
            $context = $this->sanitize($context);

            $data = \array_merge($data, $context);
        }

        $row[] = $data;

        $row[] = $LEVELS[$level] ?? self::LOG;

        if (isset($context['exception'])) {
            // NOTE: per PSR-3, this reserved key could be anything, but if it is an Exception, we
            //       can use that Exception to obtain a stack-trace for output in ChromeLogger.
            $exception = $context['exception'];

            if ($exception instanceof \Throwable) {
                $row[] = $exception->__toString();
            }
        }

        // Optimization: ChromeLogger defaults to "log" if no entry-type is specified.
        if ($row[1] === self::LOG) {
            if (\count($row) === 2) {
                unset($row[1]);
            } else {
                $row[1] = '';
            }
        }

        return $row;
    }
protected function createEntryData ( array $ entry ) : array { // NOTE: "log" level type is deliberately omitted from the following map, since //       it's the default entry-type in ChromeLogger, and can be omitted. static $ LEVELS = [ LogLevel :: DEBUG => self :: LOG , LogLevel :: INFO => self :: INFO , LogLevel :: NOTICE => self :: INFO , LogLevel :: WARNING => self :: WARN , LogLevel :: ERROR => self :: ERROR , LogLevel :: CRITICAL => self :: ERROR , LogLevel :: ALERT => self :: ERROR , LogLevel :: EMERGENCY => self :: ERROR , ] ; $ row = [ ] ; [ $ level , $ message , $ context ] = $ entry ; $ data = [ \ str_replace ( '%' , '%%' , Dumper :: interpolate ( $ message , $ context ) ) , ] ; if ( \ count ( $ context ) ) { $ context = $ this -> sanitize ( $ context ) ; $ data = \ array_merge ( $ data , $ context ) ; } $ row [ ] = $ data ; $ row [ ] = $ LEVELS [ $ level ] ?? self :: LOG ; if ( isset ( $ context [ 'exception' ] ) ) { // NOTE: per PSR-3, this reserved key could be anything, but if it is an Exception, we //       can use that Exception to obtain a stack-trace for output in ChromeLogger. $ exception = $ context [ 'exception' ] ; if ( $ exception instanceof \ Throwable ) { $ row [ ] = $ exception -> __toString ( ) ; } } // Optimization: ChromeLogger defaults to "log" if no entry-type is specified. if ( $ row [ 1 ] === self :: LOG ) { if ( \ count ( $ row ) === 2 ) { unset ( $ row [ 1 ] ) ; } else { $ row [ 1 ] = '' ; } } return $ row ; }
Encode an individual LogEntry in ChromeLogger-compatible format

@param array $entry

@return array log entry in ChromeLogger row-format
Encode an individual LogEntry in ChromeLogger - compatible format