Documentation

HtmlFormatter extends NormalizerFormatter
in package

Formats incoming records into an HTML table

This is especially useful for html email logging

Tags
author

Tiago Brito tlfbrito@gmail.com

Table of Contents

Constants

SIMPLE_DATE  = "Y-m-d\\TH:i:sP"

Properties

$basePath  : string
$dateFormat  : string
$maxNormalizeDepth  : int
$maxNormalizeItemCount  : int

Methods

__construct()  : mixed
addJsonEncodeOption()  : $this
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
normalizeValue()  : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
Normalize an arbitrary value to a scalar|array|null
removeJsonEncodeOption()  : $this
setBasePath()  : $this
Setting a base path will hide the base path from exception and stack trace file names to shorten them
setDateFormat()  : $this
setJsonPrettyPrint()  : $this
Enables `json_encode` pretty print.
setMaxNormalizeDepth()  : $this
setMaxNormalizeItemCount()  : $this
addRow()  : string
Creates an HTML table row
addTitle()  : string
Create a HTML h1 tag
convertToString()  : string
formatDate()  : string
getLevelColor()  : string
Translates Monolog log levels to html color priorities.
normalize()  : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
normalizeException()  : array<string|int, mixed>
normalizeRecord()  : array<string|int, array<string|int, mixed>|scalar|null>
Provided as extension point
toJson()  : string
Return the JSON representation of a value

Constants

Properties

Methods

__construct()

public __construct([string|null $dateFormat = null ]) : mixed
Parameters
$dateFormat : string|null = null

The format of the timestamp: one supported by DateTime::format

Tags
throws
RuntimeException

If the function json_encode does not exist

addJsonEncodeOption()

public addJsonEncodeOption(int $option) : $this
Parameters
$option : int
Return values
$this

format()

Formats a log record.

public format(LogRecord $record) : string
Parameters
$record : LogRecord

A record to format

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

getMaxNormalizeDepth()

The maximum number of normalization levels to go through

public getMaxNormalizeDepth() : int
Return values
int

getMaxNormalizeItemCount()

The maximum number of items to normalize per level

public getMaxNormalizeItemCount() : int
Return values
int

normalizeValue()

Normalize an arbitrary value to a scalar|array|null

public normalizeValue(mixed $data) : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
Parameters
$data : mixed
Return values
null|scalar|array<string|int, array<string|int, mixed>|scalar|null>

removeJsonEncodeOption()

public removeJsonEncodeOption(int $option) : $this
Parameters
$option : int
Return values
$this

setBasePath()

Setting a base path will hide the base path from exception and stack trace file names to shorten them

public setBasePath([string $path = '' ]) : $this
Parameters
$path : string = ''
Return values
$this

setDateFormat()

public setDateFormat(string $dateFormat) : $this
Parameters
$dateFormat : string
Return values
$this

setJsonPrettyPrint()

Enables `json_encode` pretty print.

public setJsonPrettyPrint(bool $enable) : $this
Parameters
$enable : bool
Return values
$this

setMaxNormalizeDepth()

public setMaxNormalizeDepth(int $maxNormalizeDepth) : $this
Parameters
$maxNormalizeDepth : int
Return values
$this

setMaxNormalizeItemCount()

public setMaxNormalizeItemCount(int $maxNormalizeItemCount) : $this
Parameters
$maxNormalizeItemCount : int
Return values
$this

addRow()

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
string

addTitle()

Create a HTML h1 tag

protected addTitle(string $title, Level $level) : string
Parameters
$title : string

Text to be in the h1

$level : Level
Return values
string

convertToString()

protected convertToString(mixed $data) : string
Parameters
$data : mixed
Return values
string

formatDate()

protected formatDate(DateTimeInterface $date) : string
Parameters
$date : DateTimeInterface
Return values
string

getLevelColor()

Translates Monolog log levels to html color priorities.

protected getLevelColor(Level $level) : string
Parameters
$level : Level
Return values
string

normalize()

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>

normalizeRecord()

Provided as extension point

protected normalizeRecord(LogRecord $record) : array<string|int, array<string|int, mixed>|scalar|null>

Because normalize is called with sub-values of context data etc, normalizeRecord can be extended when data needs to be appended on the record array but not to other normalized data.

Parameters
$record : LogRecord
Return values
array<string|int, array<string|int, mixed>|scalar|null>

toJson()

Return the JSON representation of a value

protected toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
$data : mixed
$ignoreErrors : bool = false
Tags
throws
RuntimeException

if encoding fails and errors are not ignored

Return values
string

if encoding fails and ignoreErrors is true 'null' is returned


        
On this page

Search results