Download the PHP package freshcells/guzzle-message-anonymizer-formatter without Composer
On this page you can find all versions of the php package freshcells/guzzle-message-anonymizer-formatter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download freshcells/guzzle-message-anonymizer-formatter
More information about freshcells/guzzle-message-anonymizer-formatter
Files in freshcells/guzzle-message-anonymizer-formatter
Download freshcells/guzzle-message-anonymizer-formatter
More information about freshcells/guzzle-message-anonymizer-formatter
Files in freshcells/guzzle-message-anonymizer-formatter
Vendor freshcells
Package guzzle-message-anonymizer-formatter
Short Description Anonymize Request data from guzzle before logging
License MIT
Package guzzle-message-anonymizer-formatter
Short Description Anonymize Request data from guzzle before logging
License MIT
Please rate this library. Is it a good library?
Informations about the package guzzle-message-anonymizer-formatter
Guzzle Message Anonymizer Formatter
Anonymize or truncate parts of json or xml payloads and request headers before logging with a guzzle middleware.
For data protection you might not want to log personal data, like names, addresses etc in your requests.
Usage
Example usage for Json Payloads:
...
$formatter = new GuzzleMessageJsonAnonymizerFormatter(
['PersonalData'],
$substitute = '*****',
AbstractAnonymizerFormatter::DEBUG,
['Authorization' => '*****']
);
$loggerMiddleware = Middleware::log($logger, $formatter);
$stack->push($loggerMiddleware);
$config = [
...
'handler' => $stack,
];
$client = new Client($config);
This will log:
<<<<<<<<
HTTP/1.1 200 OK
Date: Thu, 18 Jun 2020 10:04:21 GMT
Content-Type: application/json
Authorization: *****
...
{
...
"Payload": {
"Foo": "Bar",
...
"PersonalData": "*****"
},
...
}
Usage Symfony
Declare the Formatter service:
Freshcells\GuzzleMessageAnonymizerFormatter\GuzzleMessageXmlAnonymizerFormatter:
arguments:
$elements:
- 'none:FirstName'
- 'none:LastName'
$attributes:
- 'none:Customer[@Age]'
$namespaces:
none: 'http://namespace.de/middleware/payment/'
$truncateElements
VeryLongText: 200
Override existing message formatter of a logger middleware:
csa_guzzle.logger.message_formatter:
alias: 'Freshcells\GuzzleMessageAnonymizerFormatter\GuzzleMessageXMLAnonymizerFormatter'
Or declare a dedicated anonymizer_logger middleware:
guzzle.middleware.anonymizer_logger:
class: Closure
factory: ['GuzzleHttp\Middleware', log]
arguments: ['@monolog.logger', '@Freshcells\GuzzleMessageAnonymizerFormatter\GuzzleMessageXmlAnonymizerFormatter', 'info']
tags:
- { name: csa_guzzle.middleware, alias: anonymizer_logger }
All versions of guzzle-message-anonymizer-formatter with dependencies
PHP Build Version
Package Version
The package freshcells/guzzle-message-anonymizer-formatter contains the following files
Loading the files please wait ....