Memory
Less than 1 minute
Memory
In-memory logger backend implementation.
class Memory implements \Hazaar\Logger\Backend\BackendStores 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 $logMethods
__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): voidParameters
| 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): voidParameters
| 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(): voidclose
Closes the memory backend.
public close(): voidThis method is a placeholder for future resource cleanup logic.
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:23 +0000