Documentation

PHPConsoleHandler extends AbstractProcessingHandler
in package

Monolog handler for Google Chrome extension "PHP Console"

Since 2.8.0 and 3.2.0, PHPConsole is abandoned and thus we will drop this handler in Monolog 4

Display PHP error/debug log messages in Google Chrome console and notification popups, executes PHP code remotely

Usage:

  1. Install Google Chrome extension [now dead and removed from the chrome store]

  2. See overview https://github.com/barbushin/php-console#overview

  3. Install PHP Console library https://github.com/barbushin/php-console#installation

  4. Example (result will looks like http://i.hizliresim.com/vg3Pz4.png)

    $logger = new \Monolog\Logger('all', array(new \Monolog\Handler\PHPConsoleHandler())); \Monolog\ErrorHandler::register($logger); echo $undefinedVar; $logger->debug('SELECT * FROM users', array('db', 'time' => 0.012)); PC::debug($_SERVER); // PHP Console debugger for any type of vars

Tags
author

Sergey Barbushin https://www.linkedin.com/in/barbushin

phpstan-type

Options array{ enabled: bool, classesPartialsTraceIgnore: string[], debugTagsKeysInContext: array<int|string>, useOwnErrorsHandler: bool, useOwnExceptionsHandler: bool, sourcesBasePath: string|null, registerHelper: bool, serverEncoding: string|null, headersLimit: int|null, password: string|null, enableSslOnlyMode: bool, ipMasks: string[], enableEvalListener: bool, dumperDetectCallbacks: bool, dumperLevelLimit: int, dumperItemsCountLimit: int, dumperItemSizeLimit: int, dumperDumpSizeLimit: int, detectDumpTraceAndSource: bool, dataStorage: Storage|null }

InputOptions array{ enabled?: bool, classesPartialsTraceIgnore?: string[], debugTagsKeysInContext?: array<int|string>, useOwnErrorsHandler?: bool, useOwnExceptionsHandler?: bool, sourcesBasePath?: string|null, registerHelper?: bool, serverEncoding?: string|null, headersLimit?: int|null, password?: string|null, enableSslOnlyMode?: bool, ipMasks?: string[], enableEvalListener?: bool, dumperDetectCallbacks?: bool, dumperLevelLimit?: int, dumperItemsCountLimit?: int, dumperItemSizeLimit?: int, dumperDumpSizeLimit?: int, detectDumpTraceAndSource?: bool, dataStorage?: Storage|null }

Table of Contents

Properties

$bubble  : bool
$formatter  : FormatterInterface|null
$level  : Level
$processors  : array<string|int, callable>
$connector  : Connector
$options  : array<string|int, mixed>

Methods

__construct()  : mixed
__destruct()  : mixed
__sleep()  : mixed
close()  : void
Closes the handler.
getBubble()  : bool
Gets the bubbling behavior.
getConnector()  : Connector
getFormatter()  : FormatterInterface
getLevel()  : Level
Gets minimum logging level at which this handler will be triggered.
getOptions()  : array<string, mixed>
handle()  : bool
Handles a record.
handleBatch()  : void
Handles a set of records at once.
isHandling()  : bool
Checks whether the given record will be handled by this handler.
popProcessor()  : callable
pushProcessor()  : HandlerInterface
reset()  : void
setBubble()  : $this
Sets the bubbling behavior.
setFormatter()  : HandlerInterface
setLevel()  : $this
Sets minimum logging level at which this handler will be triggered.
getDefaultFormatter()  : FormatterInterface
processRecord()  : LogRecord
resetProcessors()  : void
write()  : void
Writes the record down to the log of the implementing handler
getRecordTags()  : array{string, array}
handleDebugRecord()  : void
handleErrorRecord()  : void
handleExceptionRecord()  : void
initConnector()  : Connector
initOptions()  : array<string, mixed>

Properties

$processors

protected array<string|int, callable> $processors = []
Tags
phpstan-var

array<(callable(LogRecord): LogRecord)|ProcessorInterface>

$options

private array<string|int, mixed> $options = [ 'enabled' => true, // bool Is PHP Console server enabled 'classesPartialsTraceIgnore' => ['Monolog\\'], // array Hide calls of classes started with... 'debugTagsKeysInContext' => [0, 'tag'], // bool Is PHP Console server enabled 'useOwnErrorsHandler' => false, // bool Enable errors handling 'useOwnExceptionsHandler' => false, // bool Enable exceptions handling 'sourcesBasePath' => null, // string Base path of all project sources to strip in errors source paths 'registerHelper' => true, // bool Register PhpConsole\Helper that allows short debug calls like PC::debug($var, 'ta.g.s') 'serverEncoding' => null, // string|null Server internal encoding 'headersLimit' => null, // int|null Set headers size limit for your web-server 'password' => null, // string|null Protect PHP Console connection by password 'enableSslOnlyMode' => false, // bool Force connection by SSL for clients with PHP Console installed 'ipMasks' => [], // array Set IP masks of clients that will be allowed to connect to PHP Console: array('192.168.*.*', '127.0.0.1') 'enableEvalListener' => false, // bool Enable eval request to be handled by eval dispatcher(if enabled, 'password' option is also required) 'dumperDetectCallbacks' => false, // bool Convert callback items in dumper vars to (callback SomeClass::someMethod) strings 'dumperLevelLimit' => 5, // int Maximum dumped vars array or object nested dump level 'dumperItemsCountLimit' => 100, // int Maximum dumped var same level array items or object properties number 'dumperItemSizeLimit' => 5000, // int Maximum length of any string or dumped array item 'dumperDumpSizeLimit' => 500000, // int Maximum approximate size of dumped vars result formatted in JSON 'detectDumpTraceAndSource' => false, // bool Autodetect and append trace data to debug 'dataStorage' => null, ]
Tags
phpstan-var

Options

Methods

__construct()

public __construct([array<string, mixed> $options = [] ][, Connector|null $connector = null ][, int|string|Level $level = Level::Debug ][, bool $bubble = true ]) : mixed
Parameters
$options : array<string, mixed> = []

See \Monolog\Handler\PHPConsoleHandler::$options for more details

$connector : Connector|null = null

Instance of \PhpConsole\Connector class (optional)

$level : int|string|Level = Level::Debug

The minimum logging level at which this handler will be triggered

$bubble : bool = true

Whether the messages that are handled can bubble up the stack or not

Tags
throws
RuntimeException
phpstan-param

InputOptions $options

__destruct()

public __destruct() : mixed

close()

Closes the handler.

public close() : void
Tags
inheritDoc

getBubble()

Gets the bubbling behavior.

public getBubble() : bool
Return values
bool —

true means that this handler allows bubbling. false means that bubbling is not permitted.

getLevel()

Gets minimum logging level at which this handler will be triggered.

public getLevel() : Level
Return values
Level

getOptions()

public getOptions() : array<string, mixed>
Return values
array<string, mixed>

handle()

Handles a record.

public handle(LogRecord $record) : bool
Parameters
$record : LogRecord

The record to handle

Return values
bool —

true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.

handleBatch()

Handles a set of records at once.

public handleBatch(array<string|int, mixed> $records) : void
Parameters
$records : array<string|int, mixed>

The records to handle

Tags
inheritDoc

isHandling()

Checks whether the given record will be handled by this handler.

public isHandling(LogRecord $record) : bool
Parameters
$record : LogRecord

Partial log record having only a level initialized

Tags
inheritDoc
Return values
bool

setBubble()

Sets the bubbling behavior.

public setBubble(bool $bubble) : $this
Parameters
$bubble : bool

true means that this handler allows bubbling. false means that bubbling is not permitted.

Return values
$this

setLevel()

Sets minimum logging level at which this handler will be triggered.

public setLevel(Level|LogLevel::* $level) : $this
Parameters
$level : Level|LogLevel::*

Level or level name

Tags
phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $level

Return values
$this

initConnector()

private initConnector([Connector|null $connector = null ]) : Connector
Parameters
$connector : Connector|null = null
Return values
Connector

initOptions()

private initOptions(array<string, mixed> $options) : array<string, mixed>
Parameters
$options : array<string, mixed>
Tags
phpstan-param

InputOptions $options

phpstan-return

Options

Return values
array<string, mixed>
On this page

Search results