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

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

flytachi/winter-logger
======================

Multi-runtime PSR-3 logger for Winter framework (FPM, Swoole, CLI)

v1.0.6(1mo ago)081—3.2%1MITPHPPHP &gt;=8.3

Since Apr 30Pushed 1mo agoCompare

[ Source](https://github.com/Flytachi/winter-logger)[ Packagist](https://packagist.org/packages/flytachi/winter-logger)[ RSS](/packages/flytachi-winter-logger/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (8)Used By (1)

Winter Logger
=============

[](#winter-logger)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b4829bc8cc9bfa8521a457c56eda264d94a688d49d578169aa21658cdecde19d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c7974616368692f77696e7465722d6c6f676765722e737667)](https://packagist.org/packages/flytachi/winter-logger)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)

**flytachi/winter-logger** — multi-runtime PSR-3 logger for the Winter framework. Wraps Monolog with coroutine-safe context isolation, Spring Boot-style output, and a Java-style static factory.

The library is **infrastructure-agnostic**: it knows nothing about env vars, Docker, SAPI, or Swoole detection — that responsibility belongs to the framework that boots it.

---

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

[](#requirements)

- PHP &gt;= 8.3
- `psr/log` ^3.0
- `monolog/monolog` ^3.5 *(suggested — without it every logger silently becomes `NullLogger`)*
- `ext-swoole` *(optional — required only for `CoroutineContext`)*

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

[](#installation)

```
composer require flytachi/winter-logger monolog/monolog
```

Monolog-free (every logger will be a no-op `NullLogger`):

```
composer require flytachi/winter-logger
```

---

Quick Start
-----------

[](#quick-start)

### 1. Build a `LoggerManager`

[](#1-build-a-loggermanager)

The manager accepts a ready-made config — the **framework** resolves env vars and infrastructure details before calling this:

```
use Monolog\Level;
use Flytachi\Winter\Logger\LoggerManager;
use Flytachi\Winter\Logger\Context\ProcessContext;   // FPM / CLI
// use Flytachi\Winter\Logger\Context\CoroutineContext; // Swoole

$manager = new LoggerManager(
    contextStorage: new ProcessContext(),
    channels: [
        'http' => [
            'level'        => Level::Info,
            'format'       => 'line',       // 'line' | 'json'
            'output'       => 'stderr',     // 'stdout' | 'stderr' | 'syslog' | 'file' | 'null'
            'file_path'    => null,
            'file_max'     => 30,
            'syslog_ident' => 'winter',
        ],
        'cli' => [
            'level'        => Level::Debug,
            'format'       => 'line',
            'output'       => 'stdout',
            'file_path'    => null,
            'file_max'     => 30,
            'syslog_ident' => 'winter',
        ],
    ],
);
```

### 2. Register with `LoggerFactory`

[](#2-register-with-loggerfactory)

```
use Flytachi\Winter\Logger\LoggerFactory;

LoggerFactory::setManager($manager);
```

### 3. Log from anywhere

[](#3-log-from-anywhere)

```
use Flytachi\Winter\Logger\LoggerFactory;

// Per-class logger — Java-style:
LoggerFactory::getLogger(UserService::class, 'http')->info('user created', ['id' => 42]);
LoggerFactory::getLogger($this, 'cli')->debug('job started');

// Raw channel:
LoggerFactory::channel('http')->warning('rate limit hit');

// Bound context — fields appear in every subsequent call:
$log = LoggerFactory::getLogger(self::class, 'http')->withContext(['request_id' => $id]);
$log->info('processing');
$log->info('done');
```

**Output (line format)**

```
[2024-01-01 12:00:00] [INFO ] [UserService]: user created {"id":42,"class":"App\\Service\\UserService"}
[2024-01-01 12:00:00] [WARN ] [http]: rate limit hit

```

---

Request-scoped context
----------------------

[](#request-scoped-context)

Set fields once at the start of a request/job and they appear in every log line automatically via `ContextInjectingProcessor`:

```
// At request start (FPM middleware / Swoole onRequest):
$manager->contextStorage()->set('request_id', $requestId);
$manager->contextStorage()->set('user_id',    $userId);

// At request end — must clear in long-running processes to prevent leaks:
$manager->contextStorage()->clear();
```

For **Swoole** use `CoroutineContext` — it isolates context per coroutine so concurrent requests never bleed into each other.

---

Channel config reference
------------------------

[](#channel-config-reference)

KeyTypeDescription`level``Monolog\Level`Minimum level to handle`format``'line'` | `'json'`Log format`output``'stdout'` | `'stderr'` | `'syslog'` | `'file'` | `'null'`Where to write`file_path``string|null`Required when `output=file``file_max``int`Max rotated files to keep (default `30`)`syslog_ident``string`Syslog process identifier (default `'winter'`)---

Processors
----------

[](#processors)

**`ContextInjectingProcessor`** is added to every channel automatically — no config needed.

**`SensitiveMaskingProcessor`** is optional. Add it after building the manager:

```
use Flytachi\Winter\Logger\Processor\SensitiveMaskingProcessor;

$monolog = $manager->channel('http')->monolog();
$monolog->pushProcessor(new SensitiveMaskingProcessor(['my_secret']));
```

Default masked keys: `password`, `token`, `secret`, `api_key`, `authorization`, `cookie`, `credit_card`, `cvv`, `ssn`, `pin`, and more.

---

Documentation
-------------

[](#documentation)

FileTopic[00-overview.md](docs/00-overview.md)Architecture — how the pieces fit together[01-installation.md](docs/01-installation.md)Installation, optional Monolog[02-channels.md](docs/02-channels.md)`LoggerManager`, channel config, output types[03-logger-factory.md](docs/03-logger-factory.md)`LoggerFactory`, `getLogger`, `withContext`[04-context.md](docs/04-context.md)`ProcessContext`, `CoroutineContext`, lifecycle[05-handlers-formatters.md](docs/05-handlers-formatters.md)`SafeStreamHandler`, formatters, broken pipe[06-processors.md](docs/06-processors.md)`ContextInjectingProcessor`, `SensitiveMaskingProcessor`---

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance91

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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

Every ~0 days

Total

7

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/861b81dd97c8ddfa919522d2a4e17626120bd3e3d7464857cc03784676bc74a8?d=identicon)[Flytachi](/maintainers/Flytachi)

---

Top Contributors

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

---

Tags

psr-3swooleloggermonologfpmwinter

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[inpsyde/wonolog

Monolog-based logging package for WordPress.

184631.3k7](/packages/inpsyde-wonolog)[bitrix-expert/monolog-adapter

Monolog adapter for Bitrix CMS

6566.6k](/packages/bitrix-expert-monolog-adapter)[markrogoyski/simplelog-php

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

2819.1k4](/packages/markrogoyski-simplelog-php)[atrapalo/monolog-elasticsearch

A Monolog handler and formatter that makes use of the elasticsearch/elasticsearch package

1123.0k](/packages/atrapalo-monolog-elasticsearch)

PHPackages © 2026

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