HostnameProcessor.php 664 B

1234567891011121314151617181920212223242526272829303132
  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 value of gethostname in all records
  13. */
  14. class HostnameProcessor implements ProcessorInterface
  15. {
  16. private static $host;
  17. public function __construct()
  18. {
  19. self::$host = (string) gethostname();
  20. }
  21. public function __invoke(array $record): array
  22. {
  23. $record['extra']['hostname'] = self::$host;
  24. return $record;
  25. }
  26. }