Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Logger/HTMLFormatter.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
namespace WP_Rocket\Logger;
3
+
4
+
use WP_Rocket\Dependencies\Monolog\Formatter\HtmlFormatter as MonoHtmlFormatter;
5
+
6
+
defined( 'ABSPATH' ) || exit;
7
+
8
+
/**
9
+
* Class used to format log records as HTML.
10
+
*
11
+
* @since 3.2
12
+
* @author Grégory Viguier
13
+
*/
14
+
class HTMLFormatter extends MonoHtmlFormatter {
15
+
16
+
/**
17
+
* Formats a log record.
18
+
* Compared to the parent method, it removes the "channel" row.
19
+
*
20
+
* @since 3.2
21
+
* @access public
22
+
* @author Grégory Viguier
23
+
*
24
+
* @param array $record A record to format.
25
+
* @return mixed The formatted record.
26
+
*/
27
+
public function format( array $record ): string {
28
+
$output = $this->addTitle( $record['level_name'], $record['level'] );
29
+
$output .= '<table cellspacing="1" width="100%" class="monolog-output">';
30
+
31
+
$output .= $this->addRow( 'Message', (string) $record['message'] );
32
+
$output .= $this->addRow( 'Time', $record['datetime']->format( $this->dateFormat ) ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
33
+
34
+
if ( $record['context'] ) {
35
+
$embedded_table = '<table cellspacing="1" width="100%">';
36
+
37
+
foreach ( $record['context'] as $key => $value ) {
38
+
$embedded_table .= $this->addRow( $key, $this->convertToString( $value ) );
39
+
}
40
+
41
+
$embedded_table .= '</table>';
42
+
$output .= $this->addRow( 'Context', $embedded_table, false );
43
+
}
44
+
45
+
if ( $record['extra'] ) {
46
+
$embedded_table = '<table cellspacing="1" width="100%">';
47
+
48
+
foreach ( $record['extra'] as $key => $value ) {
49
+
$embedded_table .= $this->addRow( $key, $this->convertToString( $value ) );
50
+
}
51
+
52
+
$embedded_table .= '</table>';
53
+
$output .= $this->addRow( 'Extra', $embedded_table, false );
54
+
}
55
+
56
+
return $output . '</table>';
57
+
}
58
+
}
59
+