Documentation

ChromeLoggerHandler extends BaseHandler
in package

Class ChromeLoggerHandler

Allows for logging items to the Chrome console for debugging. Requires the ChromeLogger extension installed in your browser.

Tags
see
https://craig.is/writing/chrome-logger

Table of Contents

VERSION  = 1.0
Version of this library - for ChromeLogger use.
$backtraceLevel  : int
The number of track frames returned from the backtrace.
$dateFormat  : string
Date format for logging
$handles  : array<string|int, mixed>
Handles
$header  : string
The header used to pass the data.
$json  : array<string|int, mixed>
The final data that is sent to the browser.
$levels  : array<string|int, mixed>
Maps the log levels to the ChromeLogger types.
__construct()  : mixed
Constructor
canHandle()  : bool
Checks whether the Handler will handle logging items of this log Level.
handle()  : bool
Handles logging the message.
sendLogs()  : mixed
Attaches the header and the content to the passed in request object.
setDateFormat()  : HandlerInterface
Stores the date format to use while logging messages.
format()  : array<string|int, mixed>
Converts the object to display nicely in the Chrome Logger UI.

Constants

Properties

$backtraceLevel

The number of track frames returned from the backtrace.

protected int $backtraceLevel = 0

$dateFormat

Date format for logging

protected string $dateFormat = 'Y-m-d H:i:s'

$handles

Handles

protected array<string|int, mixed> $handles

$header

The header used to pass the data.

protected string $header = 'X-ChromeLogger-Data'

$json

The final data that is sent to the browser.

protected array<string|int, mixed> $json = ['version' => self::VERSION, 'columns' => ['log', 'backtrace', 'type'], 'rows' => []]

$levels

Maps the log levels to the ChromeLogger types.

protected array<string|int, mixed> $levels = ['emergency' => 'error', 'alert' => 'error', 'critical' => 'error', 'error' => 'error', 'warning' => 'warn', 'notice' => 'warn', 'info' => 'info', 'debug' => 'info']

Methods

__construct()

Constructor

public __construct([array<string|int, mixed> $config = [] ]) : mixed
Parameters
$config : array<string|int, mixed> = []
Return values
mixed

canHandle()

Checks whether the Handler will handle logging items of this log Level.

public canHandle(string $level) : bool
Parameters
$level : string
Return values
bool

handle()

Handles logging the message.

public handle(string $level, string $message) : bool

If the handler returns false, then execution of handlers will stop. Any handlers that have not run, yet, will not be run.

Parameters
$level : string
$message : string
Return values
bool

format()

Converts the object to display nicely in the Chrome Logger UI.

protected format(mixed $object) : array<string|int, mixed>
Parameters
$object : mixed
Return values
array<string|int, mixed>

Search results