protected function buildTopLevelArrayNestedForContext(array $context)
    {
        // Context becomes the main level, so anything in context (with some caveats)
        // is moved up to the top level -- by making %context% the main 'message'
        // output in the log line.

        // Rename to prefix context variables with 'reserved' names
        $nested = [];

        foreach ($this->reservedTopLevelKeys as $key) {

            if (array_key_exists($key, $context)) {
                $nested[ $key ] = $context[ $key ];
                unset ($context[ $key ]);
            }
        }

        // The 'context' key is a special case: its value should be merged
        // into the nested context at that level.
        // (So context.context.key becomes context.key)

        if (array_key_exists('context', $context)) {

            if ( ! is_array($context['context'])) {
                $context['context'] = (array) $context['context'];
            }

            $context['context'] = array_merge($context['context'], $nested);

        } else {
            // if it does not exist yet, just make a nested context
            $context['context'] = $nested;
        }

        return $context;
    }
protected function buildTopLevelArrayNestedForContext(array $context)
    {
        // Context becomes the main level, so anything in context (with some caveats)
        // is moved up to the top level -- by making %context% the main 'message'
        // output in the log line.

        // Rename to prefix context variables with 'reserved' names
        $nested = [];

        foreach ($this->reservedTopLevelKeys as $key) {

            if (array_key_exists($key, $context)) {
                $nested[ $key ] = $context[ $key ];
                unset ($context[ $key ]);
            }
        }

        // The 'context' key is a special case: its value should be merged
        // into the nested context at that level.
        // (So context.context.key becomes context.key)

        if (array_key_exists('context', $context)) {

            if ( ! is_array($context['context'])) {
                $context['context'] = (array) $context['context'];
            }

            $context['context'] = array_merge($context['context'], $nested);

        } else {
            // if it does not exist yet, just make a nested context
            $context['context'] = $nested;
        }

        return $context;
    }
protected function buildTopLevelArrayNestedForContext ( array $ context ) { // Context becomes the main level, so anything in context (with some caveats) // is moved up to the top level -- by making %context% the main 'message' // output in the log line. // Rename to prefix context variables with 'reserved' names $ nested = [ ] ; foreach ( $ this -> reservedTopLevelKeys as $ key ) { if ( array_key_exists ( $ key , $ context ) ) { $ nested [ $ key ] = $ context [ $ key ] ; unset ( $ context [ $ key ] ) ; } } // The 'context' key is a special case: its value should be merged // into the nested context at that level. // (So context.context.key becomes context.key) if ( array_key_exists ( 'context' , $ context ) ) { if ( ! is_array ( $ context [ 'context' ] ) ) { $ context [ 'context' ] = ( array ) $ context [ 'context' ] ; } $ context [ 'context' ] = array_merge ( $ context [ 'context' ] , $ nested ) ; } else { // if it does not exist yet, just make a nested context $ context [ 'context' ] = $ nested ; } return $ context ; }
Builds an array that can be used as a basis for top level JSON encoding.

This nests reserved values under the 'context' key, where required.

@param array $context
@return array
Builds an array that can be used as a basis for top level JSON encoding .