# LogSnapshot

> Canonical Log panel snapshot holding the captured rows in their typed 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) › LogSnapshot

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

Canonical Log panel snapshot holding the captured rows in their typed form.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a log snapshot from captured rows. | `LogSnapshot` |
| [`capture()`](#method-capture) static | Converts canonical logger tuples into typed rows, deriving the previous/next links and the inter-row deltas. | `LogSnapshot` |
| [`entries()`](#method-entries) | Returns the captured log rows. | `LogSnapshot` |
| [`fromArray()`](#method-fromArray) static | Narrows the persisted log payload into a typed snapshot. | `LogSnapshot` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the panel snapshot for JSON serialization. | `LogSnapshot` |

## Method details

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

```php
public function __construct(list<PHPForge\Debug\Panel\Log\LogRow> $entries)
```

Creates a log snapshot from captured rows.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$entries` | `list<`[`LogRow`](/docs/extensions/debug-core/reference/panel/log/logrow/index.md)`>` |  |

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

```php
public static function capture(list<PHPForge\Debug\Panel\Log\LogTuple> $messages): self
```

Converts canonical logger tuples into typed rows, deriving the previous/next links and the inter-row deltas.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$messages` | `list<PHPForge\Debug\Panel\Log\LogTuple>` | Logger tuples in capture order. |

**Returns**

`self`

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

```php
public function entries(): list<PHPForge\Debug\Panel\Log\LogRow>
```

Returns the captured log rows.

**Returns**

`list<`[`LogRow`](/docs/extensions/debug-core/reference/panel/log/logrow/index.md)`>`: Captured rows in capture order.

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

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

Narrows the persisted log payload into a typed snapshot.

**Parameters**

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

**Returns**

`self`: Snapshot carrying the persisted log rows.

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

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

Returns the panel snapshot for JSON serialization.

**Returns**

`array<string, mixed>`