MemoryPeakUsageProcessor.php 756 B

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