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
Table of Contents
Constants
- VERSION = 1.0
- Version of this library - for ChromeLogger use.
Properties
- $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.
Methods
- __construct() : mixed
- Constructor
- canHandle() : bool
- Checks whether the Handler will handle logging items of this log Level.
- handle() : bool
- Handles logging the message.
- sendLogs() : void
- 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
VERSION
Version of this library - for ChromeLogger use.
public
mixed
VERSION
= 1.0
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> = []
canHandle()
Checks whether the Handler will handle logging items of this log Level.
public
canHandle(string $level) : bool
Parameters
- $level : string
Return values
boolhandle()
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
boolsendLogs()
Attaches the header and the content to the passed in request object.
public
sendLogs([ResponseInterface|null &$response = null ]) : void
Parameters
- $response : ResponseInterface|null = null
setDateFormat()
Stores the date format to use while logging messages.
public
setDateFormat(string $format) : HandlerInterface
Parameters
- $format : string
Return values
HandlerInterfaceformat()
Converts the object to display nicely in the Chrome Logger UI.
protected
format(array<string|int, mixed>|int|object|string $object) : array<string|int, mixed>
Parameters
- $object : array<string|int, mixed>|int|object|string