ChromeLoggerHandler
extends BaseHandler
in package
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<int, string>
- Handles
- $header : string
- The header used to pass the data.
-
$json
: array{version: float, columns: list
, rows: list , 1: string, 2: string}>, request_uri?: string} - The final data that is sent to the browser.
- $levels : array<string, string>
- Maps the log levels to the ChromeLogger types.
Methods
- __construct() : mixed
- 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, mixed>|string
- 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<int, string>
$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{version: float, columns: list, rows: list, 1: string, 2: string}>, request_uri?: string}
$json
= ['version' => self::VERSION, 'columns' => ['log', 'backtrace', 'type'], 'rows' => []]
$levels
Maps the log levels to the ChromeLogger types.
protected
array<string, string>
$levels
= ['emergency' => 'error', 'alert' => 'error', 'critical' => 'error', 'error' => 'error', 'warning' => 'warn', 'notice' => 'warn', 'info' => 'info', 'debug' => 'info']
Methods
__construct()
public
__construct([array{handles?: list} $config = [] ]) : mixed
Parameters
-
$config
: array{handles?: list
} = []
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
Tags
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(object|string $object) : array<string, mixed>|string
Parameters
- $object : object|string