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

Table of Contents

Properties

$bubble  : bool
$formatter  : FormatterInterface|null
$level  : Level
$processors  : array<string|int, callable>
$records  : array<string|int, LogRecord>
$recordsByLevel  : array<string|int, 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
getLevel()  : Level
Gets minimum logging level at which this handler will be triggered.
getRecords()  : array<string|int, LogRecord>
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
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.
setSkipReset()  : void
getDefaultFormatter()  : FormatterInterface
Gets the default formatter.
processRecord()  : LogRecord
resetProcessors()  : void
write()  : void
Writes the (already formatted) record down to the log of the implementing handler

Properties

$processors

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

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

$recordsByLevel

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

array<value-ofLevel::VALUES, LogRecord[]>

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|LogLevel::* $level = Level::Debug ][, bool $bubble = true ]) : mixed
Parameters
$level : int|string|Level|LogLevel::* = 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
phpstan-param

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

__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

handle()

Handles a record.

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

The record to handle

Tags
inheritDoc
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

hasAlert()

public hasAlert(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasAlertRecords()

public hasAlertRecords() : bool
Return values
bool

hasAlertThatContains()

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

hasAlertThatMatches()

public hasAlertThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasAlertThatPasses()

public hasAlertThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasCritical()

public hasCritical(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasCriticalRecords()

public hasCriticalRecords() : bool
Return values
bool

hasCriticalThatContains()

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

hasCriticalThatMatches()

public hasCriticalThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasCriticalThatPasses()

public hasCriticalThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasDebug()

public hasDebug(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasDebugRecords()

public hasDebugRecords() : bool
Return values
bool

hasDebugThatContains()

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

hasDebugThatMatches()

public hasDebugThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasDebugThatPasses()

public hasDebugThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasEmergency()

public hasEmergency(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasEmergencyRecords()

public hasEmergencyRecords() : bool
Return values
bool

hasEmergencyThatContains()

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

hasEmergencyThatMatches()

public hasEmergencyThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasEmergencyThatPasses()

public hasEmergencyThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasError()

public hasError(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasErrorRecords()

public hasErrorRecords() : bool
Return values
bool

hasErrorThatContains()

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

hasErrorThatMatches()

public hasErrorThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasErrorThatPasses()

public hasErrorThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasInfo()

public hasInfo(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasInfoRecords()

public hasInfoRecords() : bool
Return values
bool

hasInfoThatContains()

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

hasInfoThatMatches()

public hasInfoThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasInfoThatPasses()

public hasInfoThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasNotice()

public hasNotice(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasNoticeRecords()

public hasNoticeRecords() : bool
Return values
bool

hasNoticeThatContains()

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

hasNoticeThatMatches()

public hasNoticeThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasNoticeThatPasses()

public hasNoticeThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

hasRecord()

public hasRecord(string|array<string|int, mixed> $recordAssertions, Level $level) : bool
Parameters
$recordAssertions : 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 : Level
Tags
phpstan-param

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

Return values
bool

hasRecords()

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

Logging level value or name

Tags
phpstan-param

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

Return values
bool

hasRecordThatContains()

public hasRecordThatContains(string $message, Level $level) : bool
Parameters
$message : string
$level : Level
Return values
bool

hasRecordThatMatches()

public hasRecordThatMatches(string $regex, Level $level) : bool
Parameters
$regex : string
$level : Level
Return values
bool

hasRecordThatPasses()

public hasRecordThatPasses(callable $predicate, Level $level) : bool
Parameters
$predicate : callable
$level : Level
Tags
phpstan-param

callable(LogRecord, int): mixed $predicate

Return values
bool

hasWarning()

public hasWarning(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
$recordAssertions : string|array<string|int, mixed>
Return values
bool

hasWarningRecords()

public hasWarningRecords() : bool
Return values
bool

hasWarningThatContains()

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

hasWarningThatMatches()

public hasWarningThatMatches(string $regex) : bool
Parameters
$regex : string
Return values
bool

hasWarningThatPasses()

public hasWarningThatPasses(callable $predicate) : bool
Parameters
$predicate : callable
Return values
bool

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

setSkipReset()

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

write()

Writes the (already formatted) record down to the log of the implementing handler

protected write(LogRecord $record) : void
Parameters
$record : LogRecord
Tags
inheritDoc
On this page

Search results