1<?php declare(strict_types=1);
2
3/*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Monolog\Processor;
13
14/**
15 * Injects memory_get_usage in all records
16 *
17 * @see Monolog\Processor\MemoryProcessor::__construct() for options
18 * @author Rob Jensen
19 */
20class MemoryUsageProcessor extends MemoryProcessor
21{
22    /**
23     * {@inheritDoc}
24     */
25    public function __invoke(array $record): array
26    {
27        $usage = memory_get_usage($this->realUsage);
28
29        if ($this->useFormatting) {
30            $usage = $this->formatBytes($usage);
31        }
32
33        $record['extra']['memory_usage'] = $usage;
34
35        return $record;
36    }
37}
38