# LogRow

> Typed log row narrowed once from the Yii logger tuple and persisted in that form.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Log](/docs/extensions/debug-core/reference/panel/log/index.md) › LogRow

| final readonly class | `PHPForge\Debug\Panel\Log\LogRow` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelRow`](/docs/extensions/debug-core/reference/storage/panelrow/index.md) |
| Source | [`src/Panel/Log/LogRow.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Log/LogRow.php#L17) |

Typed log row narrowed once from the Yii logger tuple and persisted in that form.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-category"></span>`$category` readonly constructor | `string` | Log category attached to the message. | `LogRow` |
| <span id="property-context"></span>`$context` readonly constructor | `array<array-key, mixed>` | PSR-3 context normalized by [`LogContext::normalize()`](/docs/extensions/debug-core/reference/panel/log/logcontext/index.md#method-normalize), or `[]` when the message carried none. Default: `[]`. | `LogRow` |
| <span id="property-id"></span>`$id` readonly constructor | `int` | One-based row id assigned in capture order. | `LogRow` |
| <span id="property-idOfNext"></span>`$idOfNext` readonly constructor | `int\|null` | Row id of the next entry, or `null` for the last row of the request. | `LogRow` |
| <span id="property-idOfPrevious"></span>`$idOfPrevious` readonly constructor | `int\|null` | Row id of the previous entry, or `null` for the first row of the request. | `LogRow` |
| <span id="property-level"></span>`$level` readonly constructor | `int` | Logger level constant ([`LogLevel`](/docs/extensions/debug-core/reference/helper/loglevel/index.md)). | `LogRow` |
| <span id="property-memory"></span>`$memory` readonly constructor | `int` | Memory usage in bytes reported by the logger, or `0` when the logger omitted it. | `LogRow` |
| <span id="property-message"></span>`$message` readonly constructor | `string` | Display string for the log payload. | `LogRow` |
| <span id="property-time"></span>`$time` readonly constructor | `float` | Capture timestamp in milliseconds since the Unix epoch. | `LogRow` |
| <span id="property-timeOfPrevious"></span>`$timeOfPrevious` readonly constructor | `float` | Capture timestamp of the previous row in milliseconds, or this row's own time for the first row. | `LogRow` |
| <span id="property-timeSincePrevious"></span>`$timeSincePrevious` readonly constructor | `float` | Seconds elapsed between the previous row and this one. | `LogRow` |
| <span id="property-trace"></span>`$trace` readonly constructor | `list<array<string, mixed>>` | Backtrace frames captured at the log call site. | `LogRow` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a log row from its captured logger data. | `LogRow` |
| [`fromArray()`](#method-fromArray) static | Narrows one persisted message of the log payload into a typed row. | `LogRow` |
| [`fromLoggerTuple()`](#method-fromLoggerTuple) static | Converts one canonical logger tuple into a typed row. | `LogRow` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the typed row for JSON serialization. | `LogRow` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(int $id, string $message, int $level, string $category, float $time, float $timeOfPrevious, float $timeSincePrevious, int|null $idOfPrevious, int|null $idOfNext, int $memory, array $trace, array $context = [])
```

Creates a log row from its captured logger data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `int` |  |
| `$message` | `string` |  |
| `$level` | `int` |  |
| `$category` | `string` |  |
| `$time` | `float` |  |
| `$timeOfPrevious` | `float` |  |
| `$timeSincePrevious` | `float` |  |
| `$idOfPrevious` | `int\|null` |  |
| `$idOfNext` | `int\|null` |  |
| `$memory` | `int` |  |
| `$trace` | `array` |  |
| `$context` | `array` |  |

### fromArray() <span id="method-fromArray"></span>

```php
public static function fromArray(mixed $data, string $path): self
```

Narrows one persisted message of the log payload into a typed row.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted message, expected to be an object carrying the declared shape. |
| `$path` | `string` | JSON path of the message, used to report a malformed payload. |

**Returns**

`self`: Row carrying every persisted message field.

### fromLoggerTuple() <span id="method-fromLoggerTuple"></span>

```php
public static function fromLoggerTuple(PHPForge\Debug\Panel\Log\LogTuple $message, int $id, float $timeOfPrevious, int|null $idOfPrevious, int|null $idOfNext): self
```

Converts one canonical logger tuple into a typed row.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$message` | `PHPForge\Debug\Panel\Log\LogTuple` | Logger tuple `[message, level, category, timestamp, traces, memory, context]`; memory defaults to `0` and context to `[]`. |
| `$id` | `int` | One-based row id assigned in capture order. |
| `$timeOfPrevious` | `float` | Timestamp of the previous row in seconds; this row's own timestamp for the first. |
| `$idOfPrevious` | `int\|null` | Row id preceding this one, or `null` for the first row. |
| `$idOfNext` | `int\|null` | Row id following this one, or `null` for the last row. |

**Returns**

`self`

### jsonSerialize() <span id="method-jsonSerialize"></span>

```php
public function jsonSerialize(): array<string, mixed>
```

Returns the typed row for JSON serialization.

**Returns**

`array<string, mixed>`