MemoryProcessor::updateContext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Phoole (PHP7.2+)
5
 *
6
 * @category  Library
7
 * @package   Phoole\Logger
8
 * @copyright Copyright (c) 2019 Hong Zhang
9
 */
10
declare(strict_types=1);
11
12
namespace Phoole\Logger\Processor;
13
14
/**
15
 * Add system memory usage to log entry's context
16
 *
17
 * @package Phoole\Logger
18
 */
19
class MemoryProcessor extends ProcessorAbstract
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected function updateContext(array $context): array
25
    {
26
        $context['memory_used'] = number_format(memory_get_usage(TRUE) / 1048575, 2);
27
        $context['memory_peak'] = number_format(memory_get_peak_usage(TRUE) / 1048575, 2);
28
        return $context;
29
    }
30
}