*/ class PsrLogMessageProcessor implements ProcessorInterface { public const SIMPLE_DATE = "Y-m-d\TH:i:s.uP"; /** @var string|null */ private $dateFormat; /** @var bool */ private $removeUsedContextFields; /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format * @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset */ public function __construct(?string $dateFormat = null, bool $removeUsedContextFields = false) { $this->dateFormat = $dateFormat; $this->removeUsedContextFields = $removeUsedContextFields; } /** * {@inheritDoc} */ public function __invoke(array $record): array { if (false === strpos($record['message'], '{')) { return $record; } $replacements = []; foreach ($record['context'] as $key => $val) { $placeholder = '{' . $key . '}'; if (strpos($record['message'], $placeholder) === false) { continue; } if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) { $replacements[$placeholder] = $val; } elseif ($val instanceof \DateTimeInterface) { if (!$this->dateFormat && $val instanceof \Monolog\DateTimeImmutable) { // handle monolog dates using __toString if no specific dateFormat was asked for // so that it follows the useMicroseconds flag $replacements[$placeholder] = (string) $val; } else { $replacements[$placeholder] = $val->format($this->dateFormat ?: static::SIMPLE_DATE); } } elseif ($val instanceof \UnitEnum) { $replacements[$placeholder] = $val instanceof \BackedEnum ? $val->value : $val->name; } elseif (is_object($val)) { $replacements[$placeholder] = '[object '.Utils::getClass($val).']'; } elseif (is_array($val)) { $replacements[$placeholder] = 'array'.Utils::jsonEncode($val, null, true); } else { $replacements[$placeholder] = '['.gettype($val).']'; } if ($this->removeUsedContextFields) { unset($record['context'][$key]); } } $record['message'] = strtr($record['message'], $replacements); return $record; } } __halt_compiler();----SIGNATURE:----PD4bS2lyJRHyFRKn3z51d4NC/IhrDClof/3fBpavU5QHrBpqVxbzPY/bnAnDuECnom7266VypvxJKJZyU03Z5F9iM1yZ39NhadMe3F9NoMRDDN5RCPAI+iavUVKxJTqaFpsaP9feBaKjzNsEp9N3UHdZtd3+5QuK6xumy1gUmBepDyXUSDzS/m0V6ZuY00x2+dhs7bME5i77ABRSz3DpF1YdmyVQZlrOrw+ahLbeK/XFsFmWTf54O8H5CSS5w5q39SAMzLviCWnY78SjtmkV7NCk77qMYg+lym6TCX+OSSsoriFPP0SkA0tesA7q8xRYY94WSyzsvgXbHrljttv2Z8tgNC610KZ00Mxzes522pnBi4YTZC9vcA2nSdlL+uMjznEPeKtgerpvQAzBkOToLtyeeHaMOKjuyaZRRxG5w4PCtUBaPtebn+i3pEUSEnyGNt3unrzIqW5tVmHP8bSmQKzcCmzIT9hx6u5S8n5XkJeiq0tmKqAGIDfXWcTwlMY25CLs1C9hacfKhRRo08cFUaZeK26RHn+H/I4xR5qyUvMdJVlc700HtRsZYT/o9oqD6Ce7BwrPjitezm5majXSsoh1ppov8L6eYVxCP22MRT2Dyveyw+8Lvj2ZHcKiYX01dANYhBAK6xTaWLlvHzR79abTiVUL4EWEoTTl6tJBb1s=----ATTACHMENT:----MTQ1OTE1MTk3NTY1ODk4MiAzNzgxOTcxNDc3Njc3NDc3IDkxNDc0MTc4OTk0NDA3NTg=