PHPackages                             symfony-bro/monolog-timer-processor - 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. symfony-bro/monolog-timer-processor

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

symfony-bro/monolog-timer-processor
===================================

A processor for Monolog that adds timing info to the message contexts

v1.0.1(8y ago)13.6kMITPHP

Since Jun 28Pushed 8y ago2 watchersCompare

[ Source](https://github.com/symfony-bro/monolog-timer-processor)[ Packagist](https://packagist.org/packages/symfony-bro/monolog-timer-processor)[ Docs](https://github.com/symfony-bro/monolog-timer-processor)[ RSS](/packages/symfony-bro-monolog-timer-processor/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

monolog-timer-processor [![Build Status](https://camo.githubusercontent.com/ba50fec9af217ccc1201ea0d19af457b1af312e690722bd8457cf599c3e5c848/68747470733a2f2f7472617669732d63692e6f72672f676c6f706761722f6d6f6e6f6c6f672d74696d65722d70726f636573736f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/glopgar/monolog-timer-processor)
====================================================================================================================================================================================================================================================================================================================================================

[](#monolog-timer-processor-)

Processor for [monolog](https://github.com/Seldaek/monolog) that allows to time fragments of code by adding timers info to the message contexts.

#### Basic usage

[](#basic-usage)

```
services:
    monolog.processor.timer:
        class: Glopgar\Monolog\Processor\TimerProcessor
        calls:
            - [setMainTimer]
        tags:
            - { name: monolog.processor, handler: syslog }
```

after you must touch `monolog.processor.timer` to set `main` timer

```
$logger = new \Monolog\Logger('timer.example');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout'));

$logger->pushProcessor(new Glopgar\Monolog\Processor\TimerProcessor());

// start a timer with name: 'exampleProcess'
$logger->debug('Process started', ['timer' => ['exampleProcess' => 'start']]);
usleep(1500000);
// stop the timer
$logger->debug('Process ended', ['timer' => ['exampleProcess' => 'stop']]);
$logger->debug('Process started again', ['timer' => ['exampleProcess' => 'start']]);
usleep(2300000);
$logger->debug('Process ended', ['timer' => ['exampleProcess' => 'stop']]);
```

Log output:

```
[2016-08-10 17:07:26] timer.example.DEBUG: Process started {"timer":{"exampleProcess":"start"}} []
[2016-08-10 17:07:27] timer.example.DEBUG: Process ended {"timer":{"exampleProcess":{"time":"1.50 s.","totalTime":"1.50 s.","count":1}}} []
[2016-08-10 17:07:27] timer.example.DEBUG: Process started again {"timer":{"exampleProcess":"start"}} []
[2016-08-10 17:07:30] timer.example.DEBUG: Process ended {"timer":{"exampleProcess":{"time":"2.30 s.","totalTime":"3.81 s.","count":2}}} []

```

#### Multiple timers

[](#multiple-timers)

You can start or stop more than one timer on each log line:

```
$logger->debug('Processes started', ['timer' => ['process1' => 'start', 'process2' => 'start']]);
sleep(1);
$logger->debug('Process ended, process started', ['timer' => ['process1' => 'stop', 'process3' => 'start']]);
sleep(1);
$logger->debug('Processes ended', ['timer' => ['process2' => 'stop', 'process3' => 'stop']]);
```

Log output:

```
[2016-08-10 17:17:26] timer.example.DEBUG: Processes started {"timer":{"process1":"start","process2":"start"}} []
[2016-08-10 17:17:27] timer.example.DEBUG: Process ended, process started {"timer":{"process1":{"time":"1.00","totalTime":"1.00","count":1},"process3":"start"}} []
[2016-08-10 17:17:28] timer.example.DEBUG: Processes ended {"timer":{"process2":{"time":"2.01","totalTime":"2.01","count":1},"process3":{"time":"1.00","totalTime":"1.00","count":1}}} []

```

#### Getting timers info

[](#getting-timers-info)

You can obtain an array with all the timers information using the `TimerProcessor::getTimers` method:

This can be useful for logging the timer totals at the end of the process:

```
$timers = $processor->getTimers();
foreach ($timers as $timer => $info) {
    $logger->notice('%s executed %d times, total time: %.2f s.', $timer, $info['count'], $info['totalTime']);
}
```

Author: Gonzalo López Garmendia

[github:glopgar](https://github.com/glopgar)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

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

2

Last Release

3238d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/98cfd41b87b46d6f35c6aa1bcbc70060d716ef0170b6028339f59a4ce517f1f9?d=identicon)[tigokr](/maintainers/tigokr)

---

Top Contributors

[![glopgar](https://avatars.githubusercontent.com/u/639522?v=4)](https://github.com/glopgar "glopgar (4 commits)")[![tigokr](https://avatars.githubusercontent.com/u/606705?v=4)](https://github.com/tigokr "tigokr (3 commits)")

---

Tags

logtimerloggermonologprocessor

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/symfony-bro-monolog-timer-processor/health.svg)

```
[![Health](https://phpackages.com/badges/symfony-bro-monolog-timer-processor/health.svg)](https://phpackages.com/packages/symfony-bro-monolog-timer-processor)
```

###  Alternatives

[theorchard/monolog-cascade

Monolog extension to configure multiple loggers in the blink of an eye and access them from anywhere

1482.2M9](/packages/theorchard-monolog-cascade)[glopgar/monolog-timer-processor

A processor for Monolog that adds timing info to the message contexts

1469.6k](/packages/glopgar-monolog-timer-processor)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k6](/packages/inpsyde-wonolog)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[egeniq/monolog-gdpr

Some Monolog processors that will help in relation to the security requirements under GDPR.

538.7k](/packages/egeniq-monolog-gdpr)[bitrix-expert/monolog-adapter

Monolog adapter for Bitrix CMS

6566.3k](/packages/bitrix-expert-monolog-adapter)

PHPackages © 2026

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