Core/src/Logger/AppEngineFlexFormatter.php
public function format(array $record)
    {
        $message = parent::format($record);
        list($usec, $sec) = explode(" ", microtime());
        $usec = (int)(((float)$usec)*1000000000);
        $sec = (int)$sec;
        $payload = [
            'message' => $message,
            'timestamp'=> ['seconds' => $sec,
                           'nanos' => $usec],
            'thread' => '',
            'severity' => $record['level_name'],
        ];
        if (isset($_SERVER['HTTP_X_CLOUD_TRACE_CONTEXT'])) {
            $payload['traceId'] = explode(
                "/",
                $_SERVER['HTTP_X_CLOUD_TRACE_CONTEXT']
            )[0];
        }
        return "\n" . json_encode($payload);
    }
public function format(array $record)
    {
        $message = parent::format($record);
        list($usec, $sec) = explode(" ", microtime());
        $usec = (int)(((float)$usec)*1000000000);
        $sec = (int)$sec;
        $payload = [
            'message' => $message,
            'timestamp'=> ['seconds' => $sec,
                           'nanos' => $usec],
            'thread' => '',
            'severity' => $record['level_name'],
        ];
        if (isset($_SERVER['HTTP_X_CLOUD_TRACE_CONTEXT'])) {
            $payload['traceId'] = explode(
                "/",
                $_SERVER['HTTP_X_CLOUD_TRACE_CONTEXT']
            )[0];
        }
        return "\n" . json_encode($payload);
    }
public function format ( array $ record ) { $ message = parent :: format ( $ record ) ; list ( $ usec , $ sec ) = explode ( " " , microtime ( ) ) ; $ usec = ( int ) ( ( ( float ) $ usec ) * 1000000000 ) ; $ sec = ( int ) $ sec ; $ payload = [ 'message' => $ message , 'timestamp' => [ 'seconds' => $ sec , 'nanos' => $ usec ] , 'thread' => '' , 'severity' => $ record [ 'level_name' ] , ] ; if ( isset ( $ _SERVER [ 'HTTP_X_CLOUD_TRACE_CONTEXT' ] ) ) { $ payload [ 'traceId' ] = explode ( "/" , $ _SERVER [ 'HTTP_X_CLOUD_TRACE_CONTEXT' ] ) [ 0 ] ; } return "\n" . json_encode ( $ payload ) ; }
Get the plain text message with LineFormatter's format method and add
metadata including the trace id then return the json string.

@param array $record A record to format
@return mixed The formatted record
Get the plain text message with LineFormatter s format method and add metadata including the trace id then return the json string .