LoggingMiddleware
extends AbstractMiddleware
in package
Middleware for logging HTTP requests and responses with sensitive data sanitization
Table of Contents
Properties
Methods
- __construct() : mixed
- __invoke() : callable
- Get the Guzzle middleware callable
- configure() : void
- Set configuration for the middleware
- getName() : string
- Get the name of the middleware
- getConfig() : mixed
- Get a configuration value
- getDefaultConfig() : array<string, mixed>
- Get default configuration for the middleware
- logError() : void
- Log request error
- logRequest() : void
- Log the HTTP request
- logResponse() : void
- Log the HTTP response
- sanitizeArray() : array<string, mixed>
- Recursively sanitize an array
- sanitizeBody() : string
- Sanitize body content to remove sensitive information
- sanitizeHeaders() : array<string, array<string|int, string>>
- Sanitize headers to remove sensitive information
Properties
$config
protected
array<string, mixed>
$config
= []
$logger
private
LoggerInterface
$logger
Methods
__construct()
public
__construct(LoggerInterface $logger[, array<string, mixed> $config = [] ]) : mixed
Parameters
- $logger : LoggerInterface
- $config : array<string, mixed> = []
__invoke()
Get the Guzzle middleware callable
public
__invoke() : callable
Tags
Return values
callableconfigure()
Set configuration for the middleware
public
configure(array<string|int, mixed> $config) : void
Parameters
- $config : array<string|int, mixed>
Tags
getName()
Get the name of the middleware
public
getName() : string
Tags
Return values
stringgetConfig()
Get a configuration value
protected
getConfig(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getDefaultConfig()
Get default configuration for the middleware
protected
getDefaultConfig() : array<string, mixed>
Tags
Return values
array<string, mixed>logError()
Log request error
private
logError(mixed $reason, RequestInterface $request, string $requestId, float $elapsed) : void
Parameters
- $reason : mixed
- $request : RequestInterface
- $requestId : string
- $elapsed : float
logRequest()
Log the HTTP request
private
logRequest(RequestInterface $request, string $requestId, array<string, mixed> $options) : void
Parameters
- $request : RequestInterface
- $requestId : string
- $options : array<string, mixed>
logResponse()
Log the HTTP response
private
logResponse(ResponseInterface $response, string $requestId, float $elapsed) : void
Parameters
- $response : ResponseInterface
- $requestId : string
- $elapsed : float
sanitizeArray()
Recursively sanitize an array
private
sanitizeArray(array<string, mixed> $data) : array<string, mixed>
Parameters
- $data : array<string, mixed>
Return values
array<string, mixed>sanitizeBody()
Sanitize body content to remove sensitive information
private
sanitizeBody(string $body) : string
Parameters
- $body : string
Return values
stringsanitizeHeaders()
Sanitize headers to remove sensitive information
private
sanitizeHeaders(array<string, array<string|int, string>> $headers) : array<string, array<string|int, string>>
Parameters
- $headers : array<string, array<string|int, string>>