All Notable changes to gmponos/guzzle_logger
will be documented in this file
- Allow psr/log in version 2 and 3, like guzzlehttp/guzzle do it (44)
That was a long layoff
- Allow PHP 8
- Fix a deprecation on MultiRecordArrayHandler regarding query
- [BC] Changed the signature of
HandlerInterface::log
to allow Throwables. Now the signature is
HandlerInterface::log(
LoggerInterface $logger,
RequestInterface $request,
?ResponseInterface $response = null,
?Throwable $exception = null,
?TransferStats $stats = null,
array $options = []
)
- Allow guzzle 7
- Added parameters in MultiRecordArrayHandler in order to customize the size truncated #25
- MultiRecordArrayHandler will parse form requests as and log them as array #27
- Fixes #24. Body MUST rewind on huge responses.
- Added more classes of status codes to
ThresholdStrategy
- Set as the default strategy in all handlers the
FixedStrategy
BREAKING CHANGES
LogLevelStrategy
class is removed and it has been separated to smaller classes. Check theadded
section below.- Changed the namespaces completely. The new namespace is
GuzzleLogMiddleware
instead ofGmponos\GuzzleLogger
. Check the README file for instructions. - Changed the signature of function
HandlerInterface::log
. - Changed
ArrayHandler
toMultiRecordArrayHandler
FixedStrategy
a strategy that you are able to set one level for all your logs.ThresholdLevelStrategy
a strategy that works with thresholds depending on the status code.StatusCodeStrategy
a strategy that you are able to set a specific log level per status code.
- BREAKING CHANGE Dropped support for PHP 5 and require PHP 7.2 as minimum version.
- BREAKING CHANGE Changed the constructor function of middleware.
- From now on you can pass a handler to it's constructor. Handlers are responsible for logging request/responses.
- Removed threshold argument.
- BREAKING CHANGE Renamed the variable
$logRequestOnExceptionOnly
to$onExceptionOnly
. The purpose of this constructor argument was to log request and responses only if an exception occurs. If you were manually setting this argument as true now you must set it as false as the variables meaning is inverted. - Deprecated the option
requests
. It will be removed on my next version.
- Removed
LoggerAwareTrait
. Therefore the logger can not be set after the construction of the middleware. - Changed the variable name
$logRequests
of the constructor to$logRequestOnExceptionOnly
. - In case a message is not an
\Exception
or aMessageInterface
an Exception is thrown. - Changed all the functions except of
__construct
and__invoke
to private. Same for the properties.
- The package was reading the headers of the Request/Response and if they contained
application/json
the body was parsed into an array in order to be better readable in the logger. This has changed to match a regular expression/application\/[\w\.\+]*(json)/
in order to catch more cases. Thanks @eduarguzher #4 - According to PHPStorm indication the
ext-json
needs to be installed in order for the package to work. Therefore it was added as a requirement tocomposer.json
- A new option is added with key
sensitive
. When you make a request using guzzle you can set this option to true in order not to log the body of the request and response. Example:
$guzzle->get('/test', ['log' => ['sensitive' => true]]);
- Changed the required version of guzzle from
^6.3
to6.*
. Package should be able to work with any version6.*
ofguzzle
. - For performance reasons when a body of a request/response is bigger than 3500 characters the body is truncated.
When it was truncated a key with
summary
was added in the logs and also a key withbody
. Thebody
contained only the wording "Body was truncated because of it's size". This is changed now and thesummary
key is removed and thebody
key will contain the summary from now on. - If a Stream is not seekable or readable the body can not be logged. A wording is added instead in the key
body
.
- Created the first functionality of the middleware