Memory
Less than 1 minute
Memory
In-memory logger backend implementation.
class Memory implements \Hazaar\Logger\Interface\BackendImplements: Hazaar\Logger\Interface\Backend
Stores log entries in memory for the duration of the process. Useful for testing and temporary logging. Supports writing, reading, clearing, and closing log entries.
Properties
log
The log entries.
private array $logType: array
Methods
__construct
Constructs a new Memory logger backend.
public __construct(array $config): voidParameters
| Parameter | Type | Description |
|---|---|---|
$config | array | configuration options (not used for memory backend) |
write
Writes a log entry to the memory backend.
public write(string $level, string $message, array $context): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$level | string | Log level (e.g., 'error', 'info'). |
$message | string | log message to record |
$context | array | additional context for the log entry |
read
Read the log.
public read(?int $level): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$level | int | The log level to read. If null, all log entries are returned. |
clear
Clears all log entries from the memory backend.
public clear(): voidReturns: void
close
Closes the memory backend.
public close(): voidReturns: void
This method is a placeholder for future resource cleanup logic.
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000