*/ 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:----Fh+fRAwQIvCZkyZoiO/KOJDaCCoqY/jZ3edBVyYwI5RVyLWKbFszoGsoGEcrVSv5016OfMVA3VmN9GSdm8qZ79lcZhdZDq4kH5kwco1bkMv1tL25+ZXZF/YIDglIATbWTKtpeOSXczgkyR9Zv+U9u/VZH8rHWvqGUTv5t7wslNbIqCPrWhFFV8VQoxYl29u/Azp46l7GI/gyAcAjv8WvSDIAAjqwNRRL0fbA5czb7xv5zxU8ZIHrbT1v3y4/VQhWanDA1ZoG9+jU6tn/LEEZw5BhfUc4OtwGGyRAjysoE7mxRrCTAL6oOGGmJdBWbZHcBoA/T9Imds3I2es/OZwVhV21ky5WDPzissi8uYruWybzpVIUpoSGxi5UJEusPHuBLbkiZdOiDmqiwg8Ted55CjvsWsf6CKEKObtDvDEF4faNm4BKuxjwFDCLj2+bluPa8n63iXncNzRGdYCigGmeZNv4msxq61Ahj8uN7I+ytGDq/cTuDyjx5e+a+foWM3SMo5y/78KNt/flXzgpksRAUkHjeON8UBJw7zuhLRiT/4B06A2vYQNH7JrXweAm7ea3m1llsShmpkdSY3uYKZhfMm56HxA6r+z2pgCNp29x7KH6iYCEIZYEZQy22udi4rqGA56j5Omh8A4WKe80zOfeT4s35JQSkq7E+z/paUzSjXo=----ATTACHMENT:----MTA3MTg3Mjc5MDM3NTE5NiAyNzI1MjcxOTI2OTkyMzkzIDQyNzcxNDYxMzY0Njc5MTI=