TestHandler
extends AbstractProcessingHandler
in package
Used for testing purposes.
It records all records and gives you access to them for verification.
Tags
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
$bubble
protected
bool
$bubble
= true
$formatter
protected
FormatterInterface|null
$formatter
= null
$level
protected
Level
$level
= \Monolog\Level::Debug
$processors
protected
array<string|int, callable>
$processors
= []
Tags
$records
protected
array<string|int, LogRecord>
$records
= []
$recordsByLevel
protected
array<string|int, mixed>
$recordsByLevel
= []
Tags
$skipReset
private
bool
$skipReset
= false
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
__destruct()
public
__destruct() : mixed
__sleep()
public
__sleep() : mixed
clear()
public
clear() : void
close()
Closes the handler.
public
close() : void
Tags
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.
getFormatter()
public
getFormatter() : FormatterInterface
Tags
Return values
FormatterInterfacegetLevel()
Gets minimum logging level at which this handler will be triggered.
public
getLevel() : Level
Return values
LevelgetRecords()
public
getRecords() : array<string|int, LogRecord>
Return values
array<string|int, LogRecord>handle()
Handles a record.
public
handle(LogRecord $record) : bool
Parameters
- $record : LogRecord
-
The record to handle
Tags
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
hasAlert()
public
hasAlert(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasAlertRecords()
public
hasAlertRecords() : bool
Return values
boolhasAlertThatContains()
public
hasAlertThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasAlertThatMatches()
public
hasAlertThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasAlertThatPasses()
public
hasAlertThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasCritical()
public
hasCritical(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasCriticalRecords()
public
hasCriticalRecords() : bool
Return values
boolhasCriticalThatContains()
public
hasCriticalThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasCriticalThatMatches()
public
hasCriticalThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasCriticalThatPasses()
public
hasCriticalThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasDebug()
public
hasDebug(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasDebugRecords()
public
hasDebugRecords() : bool
Return values
boolhasDebugThatContains()
public
hasDebugThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasDebugThatMatches()
public
hasDebugThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasDebugThatPasses()
public
hasDebugThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasEmergency()
public
hasEmergency(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasEmergencyRecords()
public
hasEmergencyRecords() : bool
Return values
boolhasEmergencyThatContains()
public
hasEmergencyThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasEmergencyThatMatches()
public
hasEmergencyThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasEmergencyThatPasses()
public
hasEmergencyThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasError()
public
hasError(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasErrorRecords()
public
hasErrorRecords() : bool
Return values
boolhasErrorThatContains()
public
hasErrorThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasErrorThatMatches()
public
hasErrorThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasErrorThatPasses()
public
hasErrorThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasInfo()
public
hasInfo(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasInfoRecords()
public
hasInfoRecords() : bool
Return values
boolhasInfoThatContains()
public
hasInfoThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasInfoThatMatches()
public
hasInfoThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasInfoThatPasses()
public
hasInfoThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasNotice()
public
hasNotice(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasNoticeRecords()
public
hasNoticeRecords() : bool
Return values
boolhasNoticeThatContains()
public
hasNoticeThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasNoticeThatMatches()
public
hasNoticeThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasNoticeThatPasses()
public
hasNoticeThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolhasRecord()
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
Return values
boolhasRecords()
public
hasRecords(int|string|Level|LogLevel::* $level) : bool
Parameters
- $level : int|string|Level|LogLevel::*
-
Logging level value or name
Tags
Return values
boolhasRecordThatContains()
public
hasRecordThatContains(string $message, Level $level) : bool
Parameters
- $message : string
- $level : Level
Return values
boolhasRecordThatMatches()
public
hasRecordThatMatches(string $regex, Level $level) : bool
Parameters
- $regex : string
- $level : Level
Return values
boolhasRecordThatPasses()
public
hasRecordThatPasses(callable $predicate, Level $level) : bool
Parameters
- $predicate : callable
- $level : Level
Tags
Return values
boolhasWarning()
public
hasWarning(string|array<string|int, mixed> $recordAssertions) : bool
Parameters
- $recordAssertions : string|array<string|int, mixed>
Return values
boolhasWarningRecords()
public
hasWarningRecords() : bool
Return values
boolhasWarningThatContains()
public
hasWarningThatContains(string $message) : bool
Parameters
- $message : string
Return values
boolhasWarningThatMatches()
public
hasWarningThatMatches(string $regex) : bool
Parameters
- $regex : string
Return values
boolhasWarningThatPasses()
public
hasWarningThatPasses(callable $predicate) : bool
Parameters
- $predicate : callable
Return values
boolisHandling()
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
Return values
boolpopProcessor()
public
popProcessor() : callable
Tags
Return values
callablepushProcessor()
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Tags
Return values
HandlerInterfacereset()
public
reset() : void
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
$thissetFormatter()
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Tags
Return values
HandlerInterfacesetLevel()
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
Return values
$thissetSkipReset()
public
setSkipReset(bool $skipReset) : void
Parameters
- $skipReset : bool
getDefaultFormatter()
Gets the default formatter.
protected
getDefaultFormatter() : FormatterInterface
Overwrite this if the LineFormatter is not a good default for your handler.
Return values
FormatterInterfaceprocessRecord()
protected
processRecord(LogRecord $record) : LogRecord
Parameters
- $record : LogRecord
Return values
LogRecordresetProcessors()
protected
resetProcessors() : void
write()
Writes the (already formatted) record down to the log of the implementing handler
protected
write(LogRecord $record) : void
Parameters
- $record : LogRecord