LogCollector
API reference › Yii3 Debug › Collector › LogCollector
Captures Yiisoft log messages in the canonical Log panel shape.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a log collector that flushes and redacts application messages before capture. | LogCollector |
capture() | Encodes the captured messages into the Logs panel payload. | LogCollector |
id() | Returns the stable identifier of this collector. | LogCollector |
shutdown() | Stops capturing and clears the messages accumulated for the request. | LogCollector |
startup() | Starts capturing, discarding anything the target held from a previous request. | LogCollector |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(Yii3\Debug\Log\DebugLogTarget $target, Psr\Log\LoggerInterface|null $logger = null, PHPForge\Debug\Capture\CapturePolicy $capturePolicy = new \PHPForge\Debug\Capture\CapturePolicy())Creates a log collector that flushes and redacts application messages before capture.
Parameters
| Parameter | Type | Description |
|---|---|---|
$target | Yii3\ | Log target accumulating the messages of the request. |
$logger | Psr\ | Application logger flushed before reading, or null to skip flushing. |
$capturePolicy | CapturePolicy | Policy redacting the sensitive keys and string values of the PSR-3 context; the message text is never redacted. |
capture()
Section titled “capture() ”public function capture(): array<string, mixed>|nullEncodes the captured messages into the Logs panel payload.
Each row carries the PSR-3 context without the reserved keys, normalized into a bounded, redacted JSON tree.
Returns
array<string, mixed>|null: Encoded Logs panel payload; null when the collector never started.
public function id(): stringReturns the stable identifier of this collector.
Returns
string: Stable ID pairing this collector with its panel.
shutdown()
Section titled “shutdown() ”public function shutdown(): voidStops capturing and clears the messages accumulated for the request.
startup()
Section titled “startup() ”public function startup(): voidStarts capturing, discarding anything the target held from a previous request.