Skip to content
PHP Ecosystem
Explore

LogTarget

API reference › Debug › LogTarget

Per-request JSON snapshot collector consumed by the debug toolbar.

PropertyTypeDescriptionDefined by
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$categorieslist<string>List of message categories that this target is interested in. Default: [].yii\log\Target
$enabledbool|callableA boolean value or a callable to obtain the value from.yii\log\Target
$exceptlist<string>List of message categories that this target is NOT interested in. Default: [].yii\log\Target
$exportIntervalintHow many messages should be accumulated before they are exported. Default: 1000.yii\log\Target
$levelsarray|intMessage levels that this target is interested in.yii\log\Target
$logVarslist<string>List of the PHP predefined variables that should be logged in a message. Default: ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION', '_SERVER'].yii\log\Target
$maskVarslist<string>List of the PHP predefined variables that should NOT be logged “as is” and should always be replaced with a mask *** before logging, when exist. Default: ['_SERVER.HTTP_AUTHORIZATION', '_SERVER.PHP_AUTH_USER', '_SERVER.PHP_AUTH_PW']. Available since 2.0.16.yii\log\Target
$messageslist<yii\log\LogMessage>The messages that are retrieved from the logger so far by this log target. Default: [].yii\log\Target
$microtimeboolWhether to log time with microseconds. Default: false. Available since 2.0.13.yii\log\Target
$module constructorModuleDebugger module owning this target.LogTarget
$prefixcallable(yii\log\LogMessage): string|nullA PHP callable that returns a string to be prefixed to every exported message. Default: null.yii\log\Target
$tagstringUnique tag identifying the current request. Default: ''.LogTarget
MethodDescriptionDefined by
__construct()Adopts the owning module and registers itself as the module’s log target when none is wired yet, so collectors reading through Module::$logTarget see the messages this target accumulates.LogTarget
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
beginRequest()Starts a fresh persistent-worker request with an isolated tag and message buffer.LogTarget
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
canSetProperty()Returns a value indicating whether a property can be set.yii\base\Component
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
collect()Accumulates the flushed log messages and writes the capture once the request ends.LogTarget
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
export()Captures every panel into a typed DTO, writes one JSON snapshot, and updates the JSON manifest.LogTarget
filterMessages() staticFilters the given messages according to their categories and levels.yii\log\Target
formatMessage()Formats a log message for display as a string.yii\log\Target
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
getEnabled()Check whether the log target is enabled.yii\log\Target
getLevels()yii\log\Target
getMessagePrefix()Returns a string to be prefixed to the given message.yii\log\Target
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
init()Initializes the object.yii\base\BaseObject
loadManifest()Reads the manifest of retained captures.LogTarget
loadSnapshot()Returns the immutable snapshot envelope for a captured request.LogTarget
loadTagToPanels()Hydrates all registered panels for a tag and returns its typed request summary.LogTarget
off()Detaches an existing event handler from this component.yii\base\Component
on()Attaches an event handler to an event.yii\base\Component
setEnabled()Sets a value indicating whether this log target is enabled.yii\log\Target
setLevels()Sets the message levels that this target is interested in.yii\log\Target
trigger()Triggers an event.yii\base\Component
collectSummary() protectedCaptures the canonical manifest summary for the current request.LogTarget
formatMessageText() protectedConverts a log message value to text.yii\log\Target
getContextMessage() protectedGenerates the context information to be logged.yii\log\Target
getExcessiveDbCallersCount() protectedCounts the call sites flagged as issuing too many statements.LogTarget
getSqlTotalCount() protectedCounts the statements executed during the request.LogTarget
getTime() protectedReturns formatted (‘Y-m-d H:i:s’) timestamp for message.yii\log\Target
public function __construct(yii\debug\Module $module, array<string, mixed> $config = [])

Adopts the owning module and registers itself as the module’s log target when none is wired yet, so collectors reading through Module::$logTarget see the messages this target accumulates.

Parameters

ParameterTypeDescription
$moduleModuleDebugger module owning this target.
$configarray<string, mixed>Standard BaseObject configuration.
public function beginRequest(): void

Starts a fresh persistent-worker request with an isolated tag and message buffer.

public function collect(array<int|string, yii\debug\LogMessage> $messages, bool $final): void

Accumulates the flushed log messages and writes the capture once the request ends.

Parameters

ParameterTypeDescription
$messagesarray<int|string, yii\debug\LogMessage>Messages flushed by the logger.
$finalboolWhether this is the final flush of the request.
public function export(): void

Captures every panel into a typed DTO, writes one JSON snapshot, and updates the JSON manifest.

A failing panel is isolated as a PanelFailure; root, encoding, and filesystem failures remain explicit.

Throws

public function loadManifest(): array<string, PHPForge\Debug\Storage\RequestSummary>

Reads the manifest of retained captures.

Returns

array<string, PHPForge\Debug\Storage\RequestSummary>: Manifest entries keyed by tag, newest first.

public function loadSnapshot(string $tag): PHPForge\Debug\Storage\DebugSnapshot|null

Returns the immutable snapshot envelope for a captured request.

Unlike loadTagToPanels(), this method does not mutate the registered panel instances. It is intended for cross-request workflows such as history comparison where two captures must be inspected at the same time.

Parameters

ParameterTypeDescription
$tagstringCaptured request tag.

Returns

PHPForge\Debug\Storage\DebugSnapshot|null: Snapshot envelope, or null when the tag is unavailable.

public function loadTagToPanels(string $tag): PHPForge\Debug\Storage\RequestSummary|null

Hydrates all registered panels for a tag and returns its typed request summary.

Invalid root JSON or summary data rejects the snapshot. Invalid panel payloads are isolated as visible panel errors while the remaining panels continue to load.

Parameters

ParameterTypeDescription
$tagstringCapture to load.

Returns

PHPForge\Debug\Storage\RequestSummary|null: Summary of the capture, or null when it cannot be read.

protected function collectSummary(): PHPForge\Debug\Storage\RequestSummary

Captures the canonical manifest summary for the current request.

Returns

PHPForge\Debug\Storage\RequestSummary: Manifest entry describing the current request.

protected function getExcessiveDbCallersCount(): int

Counts the call sites flagged as issuing too many statements.

Returns

int: Number of call sites that issued at least the configured threshold of queries; 0 when the Database collector is not registered.

protected function getSqlTotalCount(): int

Counts the statements executed during the request.

Returns

int: Number of queries executed during the request; 0 when the Database collector is not registered.