PHPackages                             meritum/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. meritum/logger

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

meritum/logger
==============

Minimal PSR-3 logger that writes newline-delimited JSON to stdout

1.0.0(today)00MITPHPPHP ^8.4CI passing

Since Jun 10Pushed todayCompare

[ Source](https://github.com/MeritumIO/logger)[ Packagist](https://packagist.org/packages/meritum/logger)[ RSS](/packages/meritum-logger/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (2)Used By (0)

meritum/logger
==============

[](#meritumlogger)

Minimal PSR-3 logger that writes newline-delimited JSON to stdout. Designed for containerized environments where structured log output is consumed by a log aggregator (GCP Cloud Logging, AWS CloudWatch, Datadog, etc.).

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

[](#installation)

```
composer require meritum/logger
```

Requirements
------------

[](#requirements)

- PHP 8.4+

Usage
-----

[](#usage)

### Standalone

[](#standalone)

Instantiate `Logger` directly with a writable resource and an optional minimum log level:

```
use Meritum\Logger\Logger;

$logger = new Logger(STDOUT);
$logger->info('Application started');
$logger->error('Something went wrong', ['exception' => 'RuntimeException']);
```

The second parameter sets the minimum log level. Messages below the minimum are silently discarded:

```
$logger = new Logger(STDOUT, 'warning');

$logger->debug('ignored');   // suppressed
$logger->info('ignored');    // suppressed
$logger->warning('logged');  // written
$logger->error('logged');    // written
```

The default minimum level is `debug`, which passes all messages through.

### With the Kernel

[](#with-the-kernel)

Add `LoggerModule` to your kernel to register `Psr\Log\LoggerInterface` as a shared service:

```
use Meritum\Logger\LoggerModule;

$kernel = new Kernel(Environment::Production);
$kernel->addModule(new LoggerModule());
$kernel->boot();

$logger = $kernel->getContainer()->get(LoggerInterface::class);
```

The minimum log level is resolved in this order:

1. `LOG_LEVEL` environment variable, if set
2. `debug` in `Environment::Development`
3. `info` in all other environments

### Overriding the binding

[](#overriding-the-binding)

If you need a different logger implementation — a file-based logger, a test double, or a third-party PSR-3 library — define `LoggerInterface` in a module registered after `LoggerModule`:

```
use Psr\Log\LoggerInterface;
use Psr\Container\ContainerInterface;

$kernel->addModule(new LoggerModule());
$kernel->addModule(new class implements ModuleInterface {
    public function register(KernelInterface $kernel): void
    {
        $kernel->define(LoggerInterface::class, function (ContainerInterface $c): LoggerInterface {
            return new MyCustomLogger();
        })->share();
    }
});
```

The last definition wins, so `LoggerModule` does not need to be removed.

Log output
----------

[](#log-output)

Each message is written as a single JSON object followed by a newline. The envelope always contains these fields:

FieldTypeDescription`timestamp`stringRFC 3339 extended (e.g. `2026-06-10T14:32:01.123+00:00`)`level`stringPSR-3 level name (`debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, `emergency`)`severity`stringReduced 4-value severity for structured log sinks (`debug`, `info`, `warning`, `critical`)`message`stringThe log message`context`objectContextual data; always present, empty object when no context is providedExample output:

```
{"timestamp":"2026-06-10T14:32:01.123+00:00","level":"error","severity":"error","message":"Database connection failed","context":{"host":"db.internal","port":5432}}
```

### Severity mapping

[](#severity-mapping)

PSR-3 defines 8 log levels. The `severity` field maps these to a reduced set aligned with common structured log sinks:

PSR-3 levelSeverity`emergency``critical``alert``critical``critical``critical``error``error``warning``warning``notice``info``info``info``debug``debug`The `level` field always carries the original PSR-3 value, so no information is lost.

Log levels
----------

[](#log-levels)

Valid levels in ascending severity order:

`debug` → `info` → `notice` → `warning` → `error` → `critical` → `alert` → `emergency`

An invalid level passed to either the constructor or `log()` throws `\InvalidArgumentException`.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8147ce1d901e9fa2ec95d6408e5862025211f9ae60131e41fb115a5a0916ce4?d=identicon)[georgeff](/maintainers/georgeff)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k240.0M312](/packages/sentry-sentry)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.0M597](/packages/illuminate-log)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M181](/packages/api-platform-metadata)[pagemachine/typo3-formlog

Form log for TYPO3

23233.9k7](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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