Formats a log record.

@param array $record     a record to format
@return mixed    the formatted record
511406
public function format(array $record)
    {
        $formattedRecord = $this->formatter->format($record);

        if (is_array($formattedRecord)) {
            list($channel, $message, $backtrace, $loglevel) = $formattedRecord;

            return [
                $channel,
                $this->formatterPrefix . $message,
                $backtrace,
                $loglevel,
            ];
        }

        return $this->formatterPrefix . $formattedRecord;
    }
374567
private function file_name_for_record( array $record ) {

		$file_format = $this->file_format;

		if ( is_callable( $file_format ) ) {
			$file_format = $file_format( $record );
			is_callable( $file_format ) and $file_format = NULL;
			$this->check_file_format( $file_format ) or $file_format = '{date}.log';
		}

		$timestamp = $this->record_timestamp( $record );

		$filename = str_replace( '{date}', date( $this->date_format, $timestamp ), $file_format );
		if ( ! filter_var( filter_var( $filename, FILTER_SANITIZE_URL ), FILTER_SANITIZE_URL ) ) {
			throw new \InvalidArgumentException( 'Invalid file name format or date format for ' . __CLASS__ );
		}

		$dir = @dirname( $filename );
		if ( ! $dir || ! wp_mkdir_p( $dir ) ) {
			throw new \RuntimeException( 'It was not possible to create folder ' . $dir );
		}

		$stat      = @stat( $dir );
		$dir_perms = isset( $stat[ 'mode' ] ) ? $stat[ 'mode' ] & 0007777 : 0755;

		return [ $filename, $dir_perms ];
	}
55096
public function processRecord(array $record)
    {
        $request = $this->requestStack->getCurrentRequest();

        $record['extra']['user_ip'] = '0.0.0.0';
        if (null !== $request) {
            $record['extra']['user_ip'] = $request->getClientIp();
            $record['extra']['user_name'] = $this->securityContext->getToken()->getUsername();
        }

        $record['extra']['site_name'] = $this->context->getSiteName();
        $record['extra']['site_id'] = $this->context->getSiteId();

        return $record;
    }
1048116
protected function formatRecordsList(array $records)
    {
        return collect($records)->mapWithKeys(function ($attributes, $id) {
            if (!is_array($attributes)) {
                list($id, $attributes) = [$attributes, []];
            }

            return [$id => $attributes];
        })->all();
    }
298274
private function buildContent(array $record): string
    {
        $dataArray = [
            'notify' => $this->notify ? 'true' : 'false',
            'message' => $record['formatted'],
            'message_format' => $this->format,
            'color' => $this->getAlertColor($record['level']),
        ];

        if (!$this->validateStringLength($dataArray['message'], static::MAXIMUM_MESSAGE_LENGTH)) {
            if (function_exists('mb_substr')) {
                $dataArray['message'] = mb_substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]';
            } else {
                $dataArray['message'] = substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]';
            }
        }

        // append the sender name if it is set
        // always append it if we use the v1 api (it is required in v1)
        if ($this->name !== null) {
            $dataArray['from'] = (string) $this->name;
        }

        return http_build_query($dataArray);
    }
802658
public static function toScalarValues($record)
    {
        return array_map(
            function ($v) {
                if (!is_scalar($v)) {
                    return '<' . gettype($v) . '>';
                }
                return $v;
            },
            (array)$record
        );
    }
54928
protected function getLogRecord($record)
    {
        $prefix = $suffix = array();

        // first infos
        $date = $record['datetime']->format( $this->datetime_format );
        $prefix[] = '['.$date.']';
        if (!empty($record['ip']))
            $prefix[] = '[ip '.$record['ip'].']';
        if (!empty($record['pid']))
            $prefix[] = '[pid '.$record['pid'].']';
        $prefix[] = $record['level_name'].' :';

        // last infos
        if (!empty($record['context'])) {
            $suffix[] = '['.$this->writeArray($record['context']).']';
        }
        if (!empty($record['extra'])) {
            $suffix[] = '['.$this->writeArray($record['extra']).']';
        }

        return join(' ', $prefix).' '.preg_replace("/\n*$/", ' ', $record['message']).' '.join(' ', $suffix);
    }
1073270
protected function prepareRecord($record)
    {
        if ($record[static::REMOVE_FLAG_NAME] == 1) {
            return $record;
        }

        $prepared = [];

        /* @var Field $field */
        foreach ($this->fields as $field) {
            $columns = $field->column();

            $value = $this->fetchColumnValue($record, $columns);

            if (is_null($value)) {
                continue;
            }

            if (method_exists($field, 'prepare')) {
                $value = $field->prepare($value);
            }

            if (($field instanceof \Encore\Admin\Form\Field\Hidden) || $value != $field->original()) {
                if (is_array($columns)) {
                    foreach ($columns as $name => $column) {
                        Arr::set($prepared, $column, $value[$name]);
                    }
                } elseif (is_string($columns)) {
                    Arr::set($prepared, $columns, $value);
                }
            }
        }

        $prepared[static::REMOVE_FLAG_NAME] = $record[static::REMOVE_FLAG_NAME];

        return $prepared;
    }
1020462
def format (self, record):
        """"""
        record.hostname = self.hostname
        return logging.Formatter.format(self, record)
786483
private function processRouteMatchLogRecord(array $record)
    {
        if ($this->isAsseticLog($record)) {
            $record['message'] = '{method}: {request_uri}';

            return $record;
        }

        $context = $record['context'];

        unset($context['method']);
        unset($context['request_uri']);

        $record['context'] = array_merge(
            array($record['context']['method'] => $record['context']['request_uri']),
            $context
        );

        return $record;
    }
653754
def format(self, record):
        """"""
        format_orig = self._fmt
        self._fmt = self.get_level_fmt(record.levelno)
        record.prefix = self.prefix
        record.plugin_id = self.plugin_id
        result = logging.Formatter.format(self, record)
        self._fmt = format_orig
        return result
942252
protected function buildContent($record)
    {
        if (strlen($record['formatted']) > $this->limit) {
            $record['formatted'] = substr($record['formatted'], 0, $this->limit);
        }

        $dataArray = array(
            'From' => $this->fromNumber,
            'To'   => $this->toNumber,
            'Body' => $record['formatted'],
        );
        return json_encode($dataArray);
    }
851619
private function formatContext(array $record)
    {
        $context = $this->filterVariablesUsedAsPlaceholders($record['message'], $record['context']);
        $context = $this->formatDateTimeObjects($context);
        $context = $this->formatThrowableObjects($context);

        $contextAsString = Yaml::dump($context, $this->getInlineLevel($record), $this->prefixLength, Yaml::DUMP_OBJECT);

        if (substr($contextAsString, strpos($contextAsString, self::PHP_SERIALIZED_OBJECT_PREFIX), strlen(self::PHP_SERIALIZED_OBJECT_PREFIX)) === self::PHP_SERIALIZED_OBJECT_PREFIX) {
            $contextAsString = $this->formatSerializedObject($contextAsString);
        }

        $contextAsString = $this->formatTextBlock($contextAsString, '--> ');
        $contextAsString = rtrim($contextAsString, PHP_EOL);

        return $contextAsString;
    }
866362
private function formatLogChannel(array $record)
    {
        if (!isset($record['channel'])) {
            return '';
        }

        if ($this->isDeprecationLog($record)) {
            return '** DEPRECATION **';
        }

        if ($this->isEventNotificationLog($record)) {
            return 'NOTIFIED EVENTS';
        }

        $channel = $record['channel'];
        $channelIcons = array(
            '_event_stop' => '[!] ',
            'security' => '(!) ',
        );
        $channelIcon = array_key_exists($channel, $channelIcons) ? $channelIcons[$channel] : '';

        return sprintf('%s%s', $channelIcon, strtoupper($channel));
    }
714898
public static function parse($record): Record
    {
        if ($record instanceof Record) {
            return $record;
        }
        if ($record instanceof stdClass) {
            $record = (array)$record;
        }
        if (is_array($record)) {
            return static::make($record);
        }
        $type = gettype($record);
        if ($type === TYPE_OBJECT) {
            $type = get_class($type);
        }
        throw new SimplesRunTimeError("Record must be an array or instanceof Record '{$type}' given");
    }
208633
protected function write(array $record) {
        $header = $this->getSyslogHeader($this->logLevels[$record['level']], $record['datetime']);
        $this->socket->write($record['formatted'], $header);
    }
167435
def format(self, record):
        """"""
        if hasattr(record, 'data'):
            return "%s. DEBUG DATA=%s" % (
                logging.Formatter.format(self, record),
                record.__dict__['data'])
        return logging.Formatter.format(self, record)