Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

(no description)

File Size: 198 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

MessageFormatter:: (3 methods):
  __construct()
  format()
  headers()


Class: MessageFormatter  - X-Ref

Formats log messages using variable substitutions for requests, responses,
and other transactional data.

The following variable substitutions are supported:

- {request}:        Full HTTP request message
- {response}:       Full HTTP response message
- {ts}:             ISO 8601 date in GMT
- {date_iso_8601}   ISO 8601 date in GMT
- {date_common_log} Apache common log date using the configured timezone.
- {host}:           Host of the request
- {method}:         Method of the request
- {uri}:            URI of the request
- {version}:        Protocol version
- {target}:         Request target of the request (path + query + fragment)
- {hostname}:       Hostname of the machine that sent the request
- {code}:           Status code of the response (if available)
- {phrase}:         Reason phrase of the response  (if available)
- {error}:          Any error messages (if available)
- {req_header_*}:   Replace `*` with the lowercased name of a request header to add to the message
- {res_header_*}:   Replace `*` with the lowercased name of a response header to add to the message
- {req_headers}:    Request headers
- {res_headers}:    Response headers
- {req_body}:       Request body
- {res_body}:       Response body

__construct(?string $template = self::CLF)   X-Ref

param: string $template Log message template

format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null)   X-Ref
Returns a formatted message string.

param: RequestInterface       $request  Request that was sent
param: ResponseInterface|null $response Response that was received
param: \Throwable|null        $error    Exception that was received

headers(MessageInterface $message)   X-Ref
No description