LogTarget
API reference › Debug › LogTarget
Per-request JSON snapshot collector consumed by the debug toolbar.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$behaviors read-only | array<yii\<static>> | List of behaviors attached to this component. | yii\ |
$categories | list<string> | List of message categories that this target is interested in. Default: []. | yii\ |
$enabled | bool| | A boolean value or a callable to obtain the value from. | yii\ |
$except | list<string> | List of message categories that this target is NOT interested in. Default: []. | yii\ |
$exportInterval | int | How many messages should be accumulated before they are exported. Default: 1000. | yii\ |
$levels | array| | Message levels that this target is interested in. | yii\ |
$logVars | list<string> | List of the PHP predefined variables that should be logged in a message. Default: ['_GET',. | yii\ |
$maskVars | list<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',. Available since 2.0.16. | yii\ |
$messages | list<yii\ | The messages that are retrieved from the logger so far by this log target. Default: []. | yii\ |
$microtime | bool | Whether to log time with microseconds. Default: false. Available since 2.0.13. | yii\ |
$module constructor | Module | Debugger module owning this target. | LogTarget |
$prefix | callable(yii\ | A PHP callable that returns a string to be prefixed to every exported message. Default: null. | yii\ |
$tag | string | Unique tag identifying the current request. Default: ''. | LogTarget |
Methods
Section titled “Methods”| Method | Description | Defined 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\ |
__clone() | This method is called after the object is created by cloning an existing one. | yii\ |
__get() | Returns the value of a component property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets the value of a component property. | yii\ |
__unset() | Sets a component property to be null. | yii\ |
attachBehavior() | Attaches a behavior to this component. | yii\ |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\ |
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\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
collect() | Accumulates the flushed log messages and writes the capture once the request ends. | LogTarget |
detachBehavior() | Detaches a behavior from the component. | yii\ |
detachBehaviors() | Detaches all behaviors from the component. | yii\ |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\ |
export() | Captures every panel into a typed DTO, writes one JSON snapshot, and updates the JSON manifest. | LogTarget |
filterMessages() static | Filters the given messages according to their categories and levels. | yii\ |
formatMessage() | Formats a log message for display as a string. | yii\ |
getBehavior() | Returns the named behavior object. | yii\ |
getBehaviors() | Returns all behaviors attached to this component. | yii\ |
getEnabled() | Check whether the log target is enabled. | yii\ |
getLevels() | yii\ | |
getMessagePrefix() | Returns a string to be prefixed to the given message. | yii\ |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\ |
init() | Initializes the object. | yii\ |
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\ |
on() | Attaches an event handler to an event. | yii\ |
setEnabled() | Sets a value indicating whether this log target is enabled. | yii\ |
setLevels() | Sets the message levels that this target is interested in. | yii\ |
trigger() | Triggers an event. | yii\ |
collectSummary() protected | Captures the canonical manifest summary for the current request. | LogTarget |
formatMessageText() protected | Converts a log message value to text. | yii\ |
getContextMessage() protected | Generates the context information to be logged. | yii\ |
getExcessiveDbCallersCount() protected | Counts the call sites flagged as issuing too many statements. | LogTarget |
getSqlTotalCount() protected | Counts the statements executed during the request. | LogTarget |
getTime() protected | Returns formatted (‘Y-m-d H:i:s’) timestamp for message. | yii\ |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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
| Parameter | Type | Description |
|---|---|---|
$module | Module | Debugger module owning this target. |
$config | array<string, | Standard BaseObject configuration. |
beginRequest()
Section titled “beginRequest() ”public function beginRequest(): voidStarts a fresh persistent-worker request with an isolated tag and message buffer.
collect()
Section titled “collect() ”public function collect(array<int|string, yii\debug\LogMessage> $messages, bool $final): voidAccumulates the flushed log messages and writes the capture once the request ends.
Parameters
| Parameter | Type | Description |
|---|---|---|
$messages | array<int| | Messages flushed by the logger. |
$final | bool | Whether this is the final flush of the request. |
export()
Section titled “export() ”public function export(): voidCaptures 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
yii\base\Exception: when the debug data directory cannot be created.
loadManifest()
Section titled “loadManifest() ”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.
loadSnapshot()
Section titled “loadSnapshot() ”public function loadSnapshot(string $tag): PHPForge\Debug\Storage\DebugSnapshot|nullReturns 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
| Parameter | Type | Description |
|---|---|---|
$tag | string | Captured request tag. |
Returns
PHPForge\Debug\Storage\DebugSnapshot|null: Snapshot envelope, or null when the tag is unavailable.
loadTagToPanels()
Section titled “loadTagToPanels() ”public function loadTagToPanels(string $tag): PHPForge\Debug\Storage\RequestSummary|nullHydrates 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
| Parameter | Type | Description |
|---|---|---|
$tag | string | Capture to load. |
Returns
PHPForge\Debug\Storage\RequestSummary|null: Summary of the capture, or null when it cannot be read.
collectSummary()
Section titled “collectSummary() ”protected function collectSummary(): PHPForge\Debug\Storage\RequestSummaryCaptures the canonical manifest summary for the current request.
Returns
PHPForge\Debug\Storage\RequestSummary: Manifest entry describing the current request.
getExcessiveDbCallersCount()
Section titled “getExcessiveDbCallersCount() ”protected function getExcessiveDbCallersCount(): intCounts 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.
getSqlTotalCount()
Section titled “getSqlTotalCount() ”protected function getSqlTotalCount(): intCounts the statements executed during the request.
Returns
int: Number of queries executed during the request; 0 when the Database collector is not registered.