| 1 |
<?php |
| 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 |
|
| 12 |
/** |
| 13 |
* Injects memory_get_usage in all records |
| 14 |
* |
| 15 |
* @see Monolog\Processor\MemoryProcessor::__construct() for options |
| 16 |
* @author Rob Jensen |
| 17 |
*/ |
| 18 |
class Monolog_Processor_MemoryUsageProcessor extends Monolog_Processor_MemoryProcessor |
| 19 |
{ |
| 20 |
/** |
| 21 |
* @param array $record |
| 22 |
* |
| 23 |
* @return array |
| 24 |
*/ |
| 25 |
public function callback(array $record) |
| 26 |
{ |
| 27 |
$bytesReal = memory_get_usage(true); |
| 28 |
$formattedReal = self::formatBytes($bytesReal); |
| 29 |
$bytes = memory_get_usage(false); |
| 30 |
$formatted = self::formatBytes($bytes); |
| 31 |
|
| 32 |
$record['extra'] = array_merge( |
| 33 |
$record['extra'], |
| 34 |
array( |
| 35 |
'memory_usage' => $formatted, |
| 36 |
'memory_real_usage' => $formattedReal, |
| 37 |
) |
| 38 |
); |
| 39 |
|
| 40 |
return $record; |
| 41 |
} |
| 42 |
} |
| 43 |
|