CoolCMS API

ImportLogReader
in package

FinalYes

Paged reading of the jsonl log (detail shows a paged preview + download).

IMPORTANT: reads line by line, never file()/file_get_contents(); the log of a 100,000-item batch would otherwise exhaust admin memory. The price is one pass through the file per page, which is negligible on a local disk compared with the out-of-memory risk.

Table of Contents

Constants

LEVELS  : array<string|int, mixed> = [\App\UI\Api\Eshop\Models\Import\ImportLogWrite...
TAIL_WINDOW_BYTES  : int = 262144
`readTail()` reads only this many bytes from the end of the file (about hundreds of lines; polling must not read the whole log).

Methods

readPage()  : array{items: list>, total: int, counts: array}
readTail()  : array<int, array<string, mixed>>
Returns the last `$limit` rows of the given levels (live error overview in `status`): one pass line by line with a ring buffer, the whole file never sits in memory.

Constants

LEVELS

public array<string|int, mixed> LEVELS = [\App\UI\Api\Eshop\Models\Import\ImportLogWriter::LEVEL_ERROR, \App\UI\Api\Eshop\Models\Import\ImportLogWriter::LEVEL_WARNING, \App\UI\Api\Eshop\Models\Import\ImportLogWriter::LEVEL_INFO]

levels in order of severity

TAIL_WINDOW_BYTES

`readTail()` reads only this many bytes from the end of the file (about hundreds of lines; polling must not read the whole log).

private int TAIL_WINDOW_BYTES = 262144

Methods

readPage()

public readPage(string $absolutePath, int $page, int $perPage[, string|null $level = null ][, string|null $phase = null ]) : array{items: list>, total: int, counts: array}
Parameters
$absolutePath : string
$page : int
$perPage : int
$level : string|null = null

level filter (error/warning/info), null = all

$phase : string|null = null

phase filter (validate/execute), null = all; the validation and execution logs are two files today, the filter is a safeguard for a shared file

Return values
array{items: list>, total: int, counts: array}

readTail()

Returns the last `$limit` rows of the given levels (live error overview in `status`): one pass line by line with a ring buffer, the whole file never sits in memory.

public readTail(string $absolutePath, int $limit, array<int, string> $levels[, string|null $phase = null ]) : array<int, array<string, mixed>>
Parameters
$absolutePath : string
$limit : int
$levels : array<int, string>
$phase : string|null = null
Return values
array<int, array<string, mixed>>
On this page

Search results