1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-09 14:46:46 +02:00

convert $th content special characters to HTML and make all the tables with the same with

This commit is contained in:
Tiago Brito
2013-11-19 23:39:11 +00:00
parent 474250f5ff
commit ec974cf3a1

View File

@@ -48,9 +48,11 @@ class HtmlEmailFormatter extends NormalizerFormatter
* @param string $td Row standard cell content
* @return string
*/
private function addRow($th, $td = ' ')
private function addRow($th, $td = ' ')
{
return "<tr style=\"padding: 4px;spacing: 0;text-align: left;\">\n<th style=\"background:#cccccc\" width=\"100px\">$th:</th>\n<td style=\"padding: 4px;spacing: 0;text-align: left;background:#eeeeee\">".nl2br($td)."</td>\n</tr>";
$td = '<pre>'.htmlspecialchars($td).'</pre>';
return "<tr style=\"padding: 4px;spacing: 0;text-align: left;\">\n<th style=\"background:#cccccc\" width=\"100px\">$th:</th>\n<td style=\"padding: 4px;spacing: 0;text-align: left;background:#eeeeee\">".$td."</td>\n</tr>";
}
/**
@@ -73,7 +75,7 @@ class HtmlEmailFormatter extends NormalizerFormatter
public function format(array $record)
{
$output = $this->addTitle($this->convertToString($record['level_name']), $record['level']);
$output .= '<table>';
$output .= '<table cellspacing="1" width="100%">';
$output .= $this->addRow('Message', $this->convertToString($record['message']));
$output .= $this->addRow('Generated at', $this->convertToString($record['datetime']));
@@ -109,7 +111,7 @@ class HtmlEmailFormatter extends NormalizerFormatter
$data = $this->normalize($data);
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
return '<pre>'.json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE).'</pre>';
return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
return str_replace('\\/', '/', json_encode($data));