PHPackages                             beste/psr-testlogger - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. beste/psr-testlogger

ActiveLibrary[Testing &amp; Quality](/categories/testing)

beste/psr-testlogger
====================

PSR-3 compliant test logger for developers who like tests and want to check if their application logs messages as they expect.

1.0.0(3y ago)220.6k↓38.8%13MITPHPPHP ^8.1

Since Sep 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/beste/psr-testlogger)[ Packagist](https://packagist.org/packages/beste/psr-testlogger)[ GitHub Sponsors](https://github.com/jeromegamez)[ RSS](/packages/beste-psr-testlogger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (3)

PSR Test Logger
===============

[](#psr-test-logger)

PSR-3 compliant test logger for developers who like tests and want to check if their application logs messages as they expect.

[![Current version](https://camo.githubusercontent.com/62874700e8fd2827f09b6d15be11787bc346aa354755f55aca6ef38200ab8e06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62657374652f7073722d746573746c6f676765722e7376673f6c6f676f3d636f6d706f736572)](https://packagist.org/packages/beste/psr-testlogger)[![Packagist PHP Version Support](https://camo.githubusercontent.com/3777ea32d13da4ace53b884b0501d5e61d63131717213c40cd7670cb857ff060/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f62657374652f7073722d746573746c6f67676572)](https://packagist.org/packages/beste/psr-testlogger)[![Monthly Downloads](https://camo.githubusercontent.com/237c53781c821db1e942b81edf16edf1d12d1f18186848524491a024b8ab9e51/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f62657374652f7073722d746573746c6f676765722e737667)](https://packagist.org/packages/beste/psr-testlogger/stats)[![Total Downloads](https://camo.githubusercontent.com/7a04496272628d3b87afa0d8dc0b59eeebb27485a77f6926bf84c9abffb1d24a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62657374652f7073722d746573746c6f676765722e737667)](https://packagist.org/packages/beste/psr-testlogger/stats)[![Tests](https://github.com/beste/psr-testlogger/actions/workflows/tests.yml/badge.svg)](https://github.com/beste/psr-testlogger/actions/workflows/tests.yml)[![Sponsor](https://camo.githubusercontent.com/1004a94551d1edaf2a6da4d45ba217b79a46eb18dd7dd2d7825add0a2a8ddc4f/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6f676f3d476974487562266c6162656c3d53706f6e736f72266d6573736167653d25453225394425413426636f6c6f723d666636396234)](https://github.com/sponsors/jeromegamez)

Installation
------------

[](#installation)

```
composer require --dev beste/psr-testlogger
```

Usage
-----

[](#usage)

In your unit tests, inject the `Beste\Psr\Log\TestLogger` class into tested subjects that expect a `Prs\Log\LoggerInterface`.

The test logger records all log messages and exposes them via the `records` property which is an instance of `Beste\Psr\Log\Records`.

```
use Beste\Psr\Log\Record;
use Beste\Psr\Log\TestLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

final class Subject
{
    public function __construct(
        public readonly LoggerInterface $logger
    ) {}

    public function doSomething(): void
    {
        $this->logger->info('Doing something');
        $this->logger->warning('1st problem');
        $this->logger->warning('2nd problem');
        $this->logger->critical('Uh oh!');
    }
}

final class SubjectTest extends \PHPUnit\Framework\TestCase
{
    private TestLogger $logger;
    private Subject $subject;

    protected function setUp() : void{
        $this->logger = TestLogger::create();
    }

    /** @test */
    public function it_does_something(): void
    {
        $this->subject->doSomething();

        self::assertCount(4, $this->logger->records);

        self::assertEqualsCanonicalizing(
            [LogLevel::INFO, LogLevel::WARNING, LogLevel::CRITICAL],
            $this->logger->records->levels()
        );

        self::assertTrue($this->logger->records->includeMessagesWithLevel('info'));
        self::assertCount(1, $this->logger->records->filteredByLevel('info'));
        self::assertCount(3, $this->logger->records->filteredByLevel('info', 'warning'));

        self::assertTrue($this->logger->records->includeMessagesContaining('problem'));
        self::assertCount(2, $this->logger->records->filteredByMessageContaining('problem'));

        self::assertTrue($this->logger->records->includeMessagesMatching('/^\d{1,}(st|nd)/i'));
        self::assertCount(2, $this->logger->records->filteredByMessageMatching('/^\d{1,}(st|nd)/i'));

        // You can filter by your own criteria. If you discover criteria not natively
        // covered by the test logger, please consider a pull request.
        self::assertTrue($this->logger->records->includeMessagesBy(fn (Record $r) => str_contains($r->level, 'n')));
        self::assertCount(3, $this->logger->records->filteredBy(fn (Record $r) => str_contains($r->level, 'n')));
    }
}
```

License
-------

[](#license)

This project is published under the [MIT License](LICENSE).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1332d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8685cf532053a084f1eade7b7da00a512c02676e65f1f1bdec73d4978030a47d?d=identicon)[jeromegamez](/maintainers/jeromegamez)

---

Top Contributors

[![jeromegamez](https://avatars.githubusercontent.com/u/67554?v=4)](https://github.com/jeromegamez "jeromegamez (4 commits)")

---

Tags

logloggingphppsr-3testinglogpsr-3testinglogging

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/beste-psr-testlogger/health.svg)

```
[![Health](https://phpackages.com/badges/beste-psr-testlogger/health.svg)](https://phpackages.com/packages/beste-psr-testlogger)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[colinodell/psr-testlogger

PSR-3 compliant test logger based on psr/log v1's, but compatible with v2 and v3 too!

1712.1M47](/packages/colinodell-psr-testlogger)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[elastic/ecs-logging

Format and enrich your log files in the elastic common schema

21907.5k1](/packages/elastic-ecs-logging)[markrogoyski/simplelog-php

Powerful PSR-3 logging. So easy, it's simple.

2818.1k4](/packages/markrogoyski-simplelog-php)

PHPackages © 2026

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