*/ class HtmlFormatter extends NormalizerFormatter { /** * Translates Monolog log levels to html color priorities. * * @var array */ protected $logLevels = [ Logger::DEBUG => '#CCCCCC', Logger::INFO => '#28A745', Logger::NOTICE => '#17A2B8', Logger::WARNING => '#FFC107', Logger::ERROR => '#FD7E14', Logger::CRITICAL => '#DC3545', Logger::ALERT => '#821722', Logger::EMERGENCY => '#000000', ]; /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format */ public function __construct(?string $dateFormat = null) { parent::__construct($dateFormat); } /** * Creates an HTML table row * * @param string $th Row header content * @param string $td Row standard cell content * @param bool $escapeTd false if td content must not be html escaped */ protected function addRow(string $th, string $td = ' ', bool $escapeTd = true): string { $th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8'); if ($escapeTd) { $td = '
'.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'
'; } return "\n$th:\n".$td."\n"; } /** * Create a HTML h1 tag * * @param string $title Text to be in the h1 * @param int $level Error level * @return string */ protected function addTitle(string $title, int $level): string { $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); return '

'.$title.'

'; } /** * Formats a log record. * * @return string The formatted record */ public function format(array $record): string { $output = $this->addTitle($record['level_name'], $record['level']); $output .= ''; $output .= $this->addRow('Message', (string) $record['message']); $output .= $this->addRow('Time', $this->formatDate($record['datetime'])); $output .= $this->addRow('Channel', $record['channel']); if ($record['context']) { $embeddedTable = '
'; foreach ($record['context'] as $key => $value) { $embeddedTable .= $this->addRow((string) $key, $this->convertToString($value)); } $embeddedTable .= '
'; $output .= $this->addRow('Context', $embeddedTable, false); } if ($record['extra']) { $embeddedTable = ''; foreach ($record['extra'] as $key => $value) { $embeddedTable .= $this->addRow((string) $key, $this->convertToString($value)); } $embeddedTable .= '
'; $output .= $this->addRow('Extra', $embeddedTable, false); } return $output.''; } /** * Formats a set of log records. * * @return string The formatted set of records */ public function formatBatch(array $records): string { $message = ''; foreach ($records as $record) { $message .= $this->format($record); } return $message; } /** * @param mixed $data */ protected function convertToString($data): string { if (null === $data || is_scalar($data)) { return (string) $data; } $data = $this->normalize($data); return Utils::jsonEncode($data, JSON_PRETTY_PRINT | Utils::DEFAULT_JSON_FLAGS, true); } } __halt_compiler();----SIGNATURE:----LIRGaX3MdNNXC41QbUv4ciY2pWbL0iHvWvSmKNAkcCDgkWBFcw9C0NeBYO2AJKyGunf6U60YZcjXYfJWwqJOtV1oVkhuy45Ay9T0BTDO2L56LlkzEG6/PHNPDbzPILCkPEMwisIEMyR3OGOKVjjlkynGT9ZiaLnumYr9ZYkn9xY/SKxMqMkHHNSNHSH8Kq7NCJCSsVGPsQKxzorb4N5uLwNFZa6ma+7Ch0O9yu3SxN8TeXlky26cJo3mFI8chmMmR8sU/rFsxN7yo2NB4Scw6uIsVYY8RojyehKcOIlhFuYIkIuiEv19H0QN37ORh38TwRKuWAZPeysS8Pv2hEw2Ez0uS7M8s2DrDNt+knjTTxS9+lBhRoPNMHu5qnDFtsnS4Dh3XgtLb504tBJdaO7W8BJsPP0yEUJBA0gRuH308O4K5FibSbnkOXNQGtXTDfo0Klhf3/6NIVG6Eg19iv0R7ssHalGF5S8TRlIJSF6PiwyK3N4JagDJjP3Wu+8FS1AqMJDI7oHC4vPeWJnA6Kbt5RqLZsoL6jyQJEHxXHD2wxHgtXIm4ggFtJGTEf/SD2MlEmr/tHj84sA05/1gAvFm4+nkLFFpET9NZ869SqdqzUW1lEbMWxZLKr9DLSRLdjWnRnXsOekTY0S0ShNV6WZYfwRgtDxVlsaYgmI6CiM5CII=----ATTACHMENT:----NTY0MTIyODA3Mzc5NTc2OSA4NzE4MTQ2MjYwNTcxMTc1IDU1ODA0NjY2ODkyNTA5MTA=