Skip to content
PHP Ecosystem
Explore

LogCollector

API reference › Yii3 Debug › Collector › LogCollector

final classYii3\Debug\Collector\LogCollector
ImplementsCollectorInterface
Sourcesrc/Collector/LogCollector.php

Captures Yiisoft log messages in the canonical Log panel shape.

MethodDescriptionDefined 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
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

ParameterTypeDescription
$targetYii3\Debug\Log\DebugLogTargetLog target accumulating the messages of the request.
$loggerPsr\Log\LoggerInterface|nullApplication logger flushed before reading, or null to skip flushing.
$capturePolicyCapturePolicyPolicy redacting the sensitive keys and string values of the PSR-3 context; the message text is never redacted.
public function capture(): array<string, mixed>|null

Encodes 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(): string

Returns the stable identifier of this collector.

Returns

string: Stable ID pairing this collector with its panel.

public function shutdown(): void

Stops capturing and clears the messages accumulated for the request.

public function startup(): void

Starts capturing, discarding anything the target held from a previous request.