1<?php declare(strict_types=1); 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 12namespace Monolog\Processor; 13 14/** 15 * Injects value of gethostname in all records 16 */ 17class HostnameProcessor implements ProcessorInterface 18{ 19 /** @var string */ 20 private static $host; 21 22 public function __construct() 23 { 24 self::$host = (string) gethostname(); 25 } 26 27 /** 28 * {@inheritDoc} 29 */ 30 public function __invoke(array $record): array 31 { 32 $record['extra']['hostname'] = self::$host; 33 34 return $record; 35 } 36} 37