HtmlFormatter
extends NormalizerFormatter
in package
Formats incoming records into an HTML table
This is especially useful for html email logging
Tags
Table of Contents
Constants
- SIMPLE_DATE = "Y-m-d\\TH:i:sP"
Properties
- $dateFormat : string
- $logLevels : array<int, string>
- Translates Monolog log levels to html color priorities.
- $maxNormalizeDepth : int
- $maxNormalizeItemCount : int
- $jsonEncodeOptions : int
Methods
- __construct() : mixed
- addJsonEncodeOption() : self
- format() : string
- Formats a log record.
- formatBatch() : string
- Formats a set of log records.
- getDateFormat() : string
- getMaxNormalizeDepth() : int
- The maximum number of normalization levels to go through
- getMaxNormalizeItemCount() : int
- The maximum number of items to normalize per level
- removeJsonEncodeOption() : self
- setDateFormat() : self
- setJsonPrettyPrint() : self
- Enables `json_encode` pretty print.
- setMaxNormalizeDepth() : self
- setMaxNormalizeItemCount() : self
- addRow() : string
- Creates an HTML table row
- addTitle() : string
- Create a HTML h1 tag
- convertToString() : string
- formatDate() : string
- normalize() : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
- normalizeException() : array<string|int, mixed>
- toJson() : string
- Return the JSON representation of a value
Constants
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d\\TH:i:sP"
Properties
$dateFormat
protected
string
$dateFormat
$logLevels
Translates Monolog log levels to html color priorities.
protected
array<int, string>
$logLevels
= [\Monolog\Logger::DEBUG => '#CCCCCC', \Monolog\Logger::INFO => '#28A745', \Monolog\Logger::NOTICE => '#17A2B8', \Monolog\Logger::WARNING => '#FFC107', \Monolog\Logger::ERROR => '#FD7E14', \Monolog\Logger::CRITICAL => '#DC3545', \Monolog\Logger::ALERT => '#821722', \Monolog\Logger::EMERGENCY => '#000000']
$maxNormalizeDepth
protected
int
$maxNormalizeDepth
= 9
$maxNormalizeItemCount
protected
int
$maxNormalizeItemCount
= 1000
$jsonEncodeOptions
private
int
$jsonEncodeOptions
= \Monolog\Utils::DEFAULT_JSON_FLAGS
Methods
__construct()
public
__construct([string|null $dateFormat = null ]) : mixed
Parameters
- $dateFormat : string|null = null
-
The format of the timestamp: one supported by DateTime::format
addJsonEncodeOption()
public
addJsonEncodeOption(int $option) : self
Parameters
- $option : int
Return values
selfformat()
Formats a log record.
public
format(array<string|int, mixed> $record) : string
Parameters
- $record : array<string|int, mixed>
Return values
string —The formatted record
formatBatch()
Formats a set of log records.
public
formatBatch(array<string|int, mixed> $records) : string
Parameters
- $records : array<string|int, mixed>
-
A set of records to format
Return values
string —The formatted set of records
getDateFormat()
public
getDateFormat() : string
Return values
stringgetMaxNormalizeDepth()
The maximum number of normalization levels to go through
public
getMaxNormalizeDepth() : int
Return values
intgetMaxNormalizeItemCount()
The maximum number of items to normalize per level
public
getMaxNormalizeItemCount() : int
Return values
intremoveJsonEncodeOption()
public
removeJsonEncodeOption(int $option) : self
Parameters
- $option : int
Return values
selfsetDateFormat()
public
setDateFormat(string $dateFormat) : self
Parameters
- $dateFormat : string
Return values
selfsetJsonPrettyPrint()
Enables `json_encode` pretty print.
public
setJsonPrettyPrint(bool $enable) : self
Parameters
- $enable : bool
Return values
selfsetMaxNormalizeDepth()
public
setMaxNormalizeDepth(int $maxNormalizeDepth) : self
Parameters
- $maxNormalizeDepth : int
Return values
selfsetMaxNormalizeItemCount()
public
setMaxNormalizeItemCount(int $maxNormalizeItemCount) : self
Parameters
- $maxNormalizeItemCount : int
Return values
selfaddRow()
Creates an HTML table row
protected
addRow(string $th[, string $td = ' ' ][, bool $escapeTd = true ]) : string
Parameters
- $th : string
-
Row header content
- $td : string = ' '
-
Row standard cell content
- $escapeTd : bool = true
-
false if td content must not be html escaped
Return values
stringaddTitle()
Create a HTML h1 tag
protected
addTitle(string $title, int $level) : string
Parameters
- $title : string
-
Text to be in the h1
- $level : int
-
Error level
Return values
stringconvertToString()
protected
convertToString(mixed $data) : string
Parameters
- $data : mixed
Return values
stringformatDate()
protected
formatDate(DateTimeInterface $date) : string
Parameters
- $date : DateTimeInterface
Return values
stringnormalize()
protected
normalize(mixed $data[, int $depth = 0 ]) : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
Parameters
- $data : mixed
- $depth : int = 0
Return values
null|scalar|array<string|int, array<string|int, mixed>|scalar|null>normalizeException()
protected
normalizeException(Throwable $e[, int $depth = 0 ]) : array<string|int, mixed>
Parameters
- $e : Throwable
- $depth : int = 0
Return values
array<string|int, mixed>toJson()
Return the JSON representation of a value
protected
toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
- $data : mixed
- $ignoreErrors : bool = false
Tags
Return values
string —if encoding fails and ignoreErrors is true 'null' is returned