\Monolog\HandlerBrowserConsoleHandler

Handler sending logs to browser's javascript console with no browser extension required

Classes extending it should (in most cases) only implement write($record)

Summary

Methods
Properties
Constants
handle()
__construct()
isHandling()
handleBatch()
close()
pushProcessor()
popProcessor()
setFormatter()
getFormatter()
setLevel()
getLevel()
setBubble()
getBubble()
__destruct()
send()
reset()
No public properties found
No constants found
write()
processRecord()
getDefaultFormatter()
registerShutdownFunction()
writeOutput()
getResponseFormat()
$level
$bubble
$formatter
$processors
$initialized
$records
N/A
generateScript()
handleStyles()
handleCustomStyles()
dump()
quote()
call()
call_array()
No private properties found
N/A

Properties

$level

$level : 

Type

$bubble

$bubble : 

Type

$processors

$processors : 

Type

$initialized

$initialized : 

Type

$records

$records : 

Type

Methods

handle()

handle(array  $record) 

{@inheritdoc}

Parameters

array $record

__construct()

__construct(integer  $level = \Monolog\Logger::DEBUG, Boolean  $bubble = true) 

Parameters

integer $level

The minimum logging level at which this handler will be triggered

Boolean $bubble

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

isHandling()

isHandling(array  $record) : Boolean

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

This is mostly done for performance reasons, to avoid calling processors for nothing.

Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.

Parameters

array $record

Partial log record containing only a level key

Returns

Boolean

handleBatch()

handleBatch(array  $records) 

Handles a set of records at once.

Parameters

array $records

The records to handle (an array of record arrays)

close()

close() 

Closes the handler.

This will be called automatically when the object is destroyed

pushProcessor()

pushProcessor(callable  $callback) : self

Adds a processor in the stack.

Parameters

callable $callback

Returns

self

popProcessor()

popProcessor() : callable

Removes the processor on top of the stack and returns it.

Returns

callable

setLevel()

setLevel(integer|string  $level) : self

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

Parameters

integer|string $level

Level or level name

Returns

self

getLevel()

getLevel() : integer

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

Returns

integer

setBubble()

setBubble(Boolean  $bubble) : self

Sets the bubbling behavior.

Parameters

Boolean $bubble

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

Returns

self

getBubble()

getBubble() : Boolean

Gets the bubbling behavior.

Returns

Boolean —

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

__destruct()

__destruct() 

send()

send() 

Convert records to javascript console commands and send it to the browser.

This method is automatically called on PHP shutdown if output is HTML or Javascript.

reset()

reset() 

Forget all logged records

write()

write(array  $record) : void

Writes the record down to the log of the implementing handler

Parameters

array $record

processRecord()

processRecord(array  $record) : array

Processes a record.

Parameters

array $record

Returns

array

getDefaultFormatter()

getDefaultFormatter() 

{@inheritDoc}

Formatted output may contain some formatting markers to be transferred to console.log using the %c format.

Example of formatted string:

You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white}

registerShutdownFunction()

registerShutdownFunction() 

Wrapper for register_shutdown_function to allow overriding

writeOutput()

writeOutput(string  $str) 

Wrapper for echo to allow overriding

Parameters

string $str

getResponseFormat()

getResponseFormat() : string

Checks the format of the response

If Content-Type is set to application/javascript or text/javascript -> js If Content-Type is set to text/html, or is unset -> html If Content-Type is anything else -> unknown

Returns

string —

One of 'js', 'html' or 'unknown'

generateScript()

generateScript() 

handleStyles()

handleStyles(  $formatted) 

Parameters

$formatted

handleCustomStyles()

handleCustomStyles(  $style,   $string) 

Parameters

$style
$string

dump()

dump(  $title, array  $dict) 

Parameters

$title
array $dict

quote()

quote(  $arg) 

Parameters

$arg

call()

call() 

call_array()

call_array(  $method, array  $args) 

Parameters

$method
array $args