MemoryPeakUsageProcessor.php 790 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  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. /**
  20. * @param array $record
  21. * @return array
  22. */
  23. public function __invoke(array $record)
  24. {
  25. $bytes = memory_get_peak_usage($this->realUsage);
  26. $formatted = $this->formatBytes($bytes);
  27. $record['extra']['memory_peak_usage'] = $formatted;
  28. return $record;
  29. }
  30. }