Documentation

TestHandler extends AbstractProcessingHandler
in package

Used for testing purposes.

It records all records and gives you access to them for verification.

Tags
author

Jordi Boggiano j.boggiano@seld.be

phpstan-import-type

Record from \Monolog\Logger

phpstan-import-type

Level from \Monolog\Logger

phpstan-import-type

LevelName from \Monolog\Logger

Table of Contents

Properties

$bubble  : bool
$formatter  : FormatterInterface|null
$level  : int
$processors  : array<string|int, callable>
$records  : array<string|int, Record>
$recordsByLevel  : mixed
$skipReset  : bool

Methods

__call()  : bool
__construct()  : mixed
__destruct()  : mixed
__sleep()  : mixed
clear()  : void
close()  : void
Closes the handler.
getBubble()  : bool
Gets the bubbling behavior.
getFormatter()  : FormatterInterface
{@inheritDoc}
getLevel()  : int
Gets minimum logging level at which this handler will be triggered.
getRecords()  : array<string|int, mixed>
handle()  : bool
Handles a record.
handleBatch()  : void
Handles a set of records at once.
hasAlert()  : bool
hasAlertRecords()  : bool
hasAlertThatContains()  : bool
hasAlertThatMatches()  : bool
hasAlertThatPasses()  : bool
hasCritical()  : bool
hasCriticalRecords()  : bool
hasCriticalThatContains()  : bool
hasCriticalThatMatches()  : bool
hasCriticalThatPasses()  : bool
hasDebug()  : bool
hasDebugRecords()  : bool
hasDebugThatContains()  : bool
hasDebugThatMatches()  : bool
hasDebugThatPasses()  : bool
hasEmergency()  : bool
hasEmergencyRecords()  : bool
hasEmergencyThatContains()  : bool
hasEmergencyThatMatches()  : bool
hasEmergencyThatPasses()  : bool
hasError()  : bool
hasErrorRecords()  : bool
hasErrorThatContains()  : bool
hasErrorThatMatches()  : bool
hasErrorThatPasses()  : bool
hasInfo()  : bool
hasInfoRecords()  : bool
hasInfoThatContains()  : bool
hasInfoThatMatches()  : bool
hasInfoThatPasses()  : bool
hasNotice()  : bool
hasNoticeRecords()  : bool
hasNoticeThatContains()  : bool
hasNoticeThatMatches()  : bool
hasNoticeThatPasses()  : bool
hasRecord()  : bool
hasRecords()  : bool
hasRecordThatContains()  : bool
hasRecordThatMatches()  : bool
hasRecordThatPasses()  : bool
hasWarning()  : bool
hasWarningRecords()  : bool
hasWarningThatContains()  : bool
hasWarningThatMatches()  : bool
hasWarningThatPasses()  : bool
isHandling()  : bool
Checks whether the given record will be handled by this handler.
popProcessor()  : callable
{@inheritDoc}
pushProcessor()  : HandlerInterface
{@inheritDoc}
reset()  : void
setBubble()  : self
Sets the bubbling behavior.
setFormatter()  : HandlerInterface
{@inheritDoc}
setLevel()  : self
Sets minimum logging level at which this handler will be triggered.
setSkipReset()  : void
getDefaultFormatter()  : FormatterInterface
Gets the default formatter.
processRecord()  : array<string|int, mixed>
Processes a record.
resetProcessors()  : void
write()  : void
Writes the record down to the log of the implementing handler

Properties

$level

protected int $level = \Monolog\Logger::DEBUG
Tags
phpstan-var

Level

$processors

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

array<ProcessorInterface|callable(Record): Record>

$records

protected array<string|int, Record> $records = []

$recordsByLevel

protected mixed $recordsByLevel = []

Methods

__call()

public __call(string $method, array<string|int, mixed> $args) : bool
Parameters
$method : string
$args : array<string|int, mixed>
Return values
bool

__construct()

public __construct([int|string $level = Logger::DEBUG ][, bool $bubble = true ]) : mixed
Parameters
$level : int|string = Logger::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
phpstan-param

Level|LevelName|LogLevel::* $level

__destruct()

public __destruct() : mixed

close()

Closes the handler.

public close() : void

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() : int
Tags
phpstan-return

Level

Return values
int

getRecords()

public getRecords() : array<string|int, mixed>
Tags
phpstan-return

Record[]

Return values
array<string|int, mixed>

handle()

Handles a record.

public handle(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>

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 (an array of record arrays)

hasAlert()

public hasAlert(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasAlertRecords()

public hasAlertRecords() : bool
Return values
bool

hasAlertThatContains()

public hasAlertThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasAlertThatMatches()

public hasAlertThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasAlertThatPasses()

public hasAlertThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasCritical()

public hasCritical(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasCriticalRecords()

public hasCriticalRecords() : bool
Return values
bool

hasCriticalThatContains()

public hasCriticalThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasCriticalThatMatches()

public hasCriticalThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasCriticalThatPasses()

public hasCriticalThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasDebug()

public hasDebug(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasDebugRecords()

public hasDebugRecords() : bool
Return values
bool

hasDebugThatContains()

public hasDebugThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasDebugThatMatches()

public hasDebugThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasDebugThatPasses()

public hasDebugThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasEmergency()

public hasEmergency(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasEmergencyRecords()

public hasEmergencyRecords() : bool
Return values
bool

hasEmergencyThatContains()

public hasEmergencyThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasEmergencyThatMatches()

public hasEmergencyThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasEmergencyThatPasses()

public hasEmergencyThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasError()

public hasError(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasErrorRecords()

public hasErrorRecords() : bool
Return values
bool

hasErrorThatContains()

public hasErrorThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasErrorThatMatches()

public hasErrorThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasErrorThatPasses()

public hasErrorThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasInfo()

public hasInfo(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasInfoRecords()

public hasInfoRecords() : bool
Return values
bool

hasInfoThatContains()

public hasInfoThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasInfoThatMatches()

public hasInfoThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasInfoThatPasses()

public hasInfoThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasNotice()

public hasNotice(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasNoticeRecords()

public hasNoticeRecords() : bool
Return values
bool

hasNoticeThatContains()

public hasNoticeThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasNoticeThatMatches()

public hasNoticeThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasNoticeThatPasses()

public hasNoticeThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasRecord()

public hasRecord(string|array<string|int, mixed> $record, string|int $level) : bool
Parameters
$record : string|array<string|int, mixed>

Either a message string or an array containing message and optionally context keys that will be checked against all records

$level : string|int

Logging level value or name

Tags
phpstan-param

array{message: string, context?: mixed[]}|string $record

phpstan-param

Level|LevelName|LogLevel::* $level

Return values
bool

hasRecords()

public hasRecords(string|int $level) : bool
Parameters
$level : string|int

Logging level value or name

Tags
phpstan-param

Level|LevelName|LogLevel::* $level

Return values
bool

hasRecordThatContains()

public hasRecordThatContains(string $message, string|int $level) : bool
Parameters
$message : string
$level : string|int

Logging level value or name

Tags
phpstan-param

Level|LevelName|LogLevel::* $level

Return values
bool

hasRecordThatMatches()

public hasRecordThatMatches(string $regex, string|int $level) : bool
Parameters
$regex : string
$level : string|int

Logging level value or name

Tags
phpstan-param

Level|LevelName|LogLevel::* $level

Return values
bool

hasRecordThatPasses()

public hasRecordThatPasses(callable $predicate, string|int $level) : bool
Parameters
$predicate : callable
$level : string|int

Logging level value or name

Tags
psalm-param

callable(Record, int): mixed $predicate

phpstan-param

Level|LevelName|LogLevel::* $level

Return values
bool

hasWarning()

public hasWarning(mixed $record) : bool
Parameters
$record : mixed
Return values
bool

hasWarningRecords()

public hasWarningRecords() : bool
Return values
bool

hasWarningThatContains()

public hasWarningThatContains(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasWarningThatMatches()

public hasWarningThatMatches(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

hasWarningThatPasses()

public hasWarningThatPasses(mixed $message) : bool
Parameters
$message : mixed
Return values
bool

isHandling()

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

public isHandling(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>

Partial log record containing only a level key

Return values
bool

setBubble()

Sets the bubbling behavior.

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

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

Return values
self

setLevel()

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

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

Level or level name

Return values
self

setSkipReset()

public setSkipReset(bool $skipReset) : void
Parameters
$skipReset : bool

processRecord()

Processes a record.

protected processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Tags
phpstan-param

Record $record

phpstan-return

Record

Return values
array<string|int, mixed>

write()

Writes the record down to the log of the implementing handler

protected write(array<string|int, mixed> $record) : void
Parameters
$record : array<string|int, mixed>

        
On this page

Search results