PHPackages                             placetopay/guzzle-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. placetopay/guzzle-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

placetopay/guzzle-logger
========================

2.0.5(7mo ago)47.2k↓25.3%1MITPHPPHP ^8.3CI passing

Since Jun 28Pushed 7mo ago4 watchersCompare

[ Source](https://github.com/placetopay-org/guzzle-logger)[ Packagist](https://packagist.org/packages/placetopay/guzzle-logger)[ RSS](/packages/placetopay-guzzle-logger/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (10)Versions (19)Used By (0)

Guzzle Log Middleware
=====================

[](#guzzle-log-middleware)

[![Quality Gate Status](https://camo.githubusercontent.com/8cc92c1b8168d53989a87e9d5853b8b918e08d38ebf54dfe551d690cb22d187a/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d706c616365746f7061795f67757a7a6c652d6c6f67676572266d65747269633d616c6572745f73746174757326746f6b656e3d34643030336262616632326437303538333032623139326266303937353266613437303664343334)](https://sonarcloud.io/summary/new_code?id=placetopay_guzzle-logger)

This is a middleware for [guzzle](https://github.com/guzzle/guzzle) that will help you automatically log every request and response using a PSR-3 logger.

The middleware is functional with version 7 of Guzzle.

Usage
-----

[](#usage)

### Simple usage

[](#simple-usage)

From now on each request and response you execute using `$client` object will be logged. By default, the middleware logs every activity with level `INFO`.

```
use PlacetoPay\GuzzleLogger\Middleware\HttpLogMiddleware;
use GuzzleHttp\HandlerStack;

$logger = new Logger();  //A new PSR-3 Logger like Monolog
$stack = HandlerStack::create(); // will create a stack with middlewares of guzzle already pushed inside of it.
$stack->push(new HttpLogMiddleware($logger));
$client = new GuzzleHttp\Client([
    'handler' => $stack,
]);
```

### With Sanitizer

[](#with-sanitizer)

With the LoggerWithSanitizer class you can obfuscate or sanitize sensitive data when logging.

fieldsToSanitize is a key-value array, with which you can determine the level of data to sanitize and the value with which to obfuscate the value. If you do not send a value and the value is found it will be sanitized with a default value `ValueSanitizer::DEFAULT`.

```
use PlacetoPay\GuzzleLogger\Middleware\HttpLogMiddleware;
use PlacetoPay\GuzzleLogger\LoggerWithSanitizer;
use PlacetoPay\GuzzleLogger\ValueSanitizer;
use GuzzleHttp\HandlerStack;

use GuzzleLogger\ValueSanitizer;

$fieldsToSanitize = [
            'request.body.instrument.card.cvv',
            'request.body.instrument.card.number' => ValueSanitizer::CARD_NUMBER->value,
            'request.body.instrument.card.expiration' => ValueSanitizer::DEFAULT->value,
            'response.body.instrument.card.number' => fn ($value) => preg_replace('/(\d{6})(\d{3,9})(\d{4})/', '$1····$3', (string) $value)
];

$stack = HandlerStack::create();
$logger = new LoggerWithSanitizer(new Logger(), $fieldsToSanitize)
$stack->push(new HttpLogMiddleware($logger));
$client = new GuzzleHttp\Client([
    'handler' => $stack,
]);
```

### Using options on each request

[](#using-options-on-each-request)

You can set on each request options about your log.

nameType valuedescription`statistics`booleanoption is true the middleware will log statistics about the HTTP call.```
$client->get('/', [
    'log' => [
        'statistics' => true,
    ]
]);
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance62

Regular maintenance activity

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~96 days

Recently: every ~67 days

Total

10

Last Release

231d ago

Major Versions

v0.1.1 → v1.0.02023-11-22

v1.0.1 → v2.0.02024-11-19

PHP version history (3 changes)v0.1.0PHP ^8.1

v1.0.0PHP ^8.2

v2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/188a6d118a8949533ff4154931c90b50f20e0fdebfb98831fd215a50430cfa67?d=identicon)[placetopay](/maintainers/placetopay)

---

Top Contributors

[![andrextor](https://avatars.githubusercontent.com/u/26684203?v=4)](https://github.com/andrextor "andrextor (18 commits)")[![eduarguz](https://avatars.githubusercontent.com/u/14934055?v=4)](https://github.com/eduarguz "eduarguz (9 commits)")

---

Tags

guzzle-middlewarehttploggerphp8

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/placetopay-guzzle-logger/health.svg)

```
[![Health](https://phpackages.com/badges/placetopay-guzzle-logger/health.svg)](https://phpackages.com/packages/placetopay-guzzle-logger)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
