CoolCMS API

ImportLogWriter
in package

FinalYes

Row log of the import: a **jsonl** file in `privateDir`, one JSON object per row: `{phase, line, code, action, level, message, key?, value?}`.

Why a file and not a table: the design deliberately creates no row table in the DB; the job holds only counts and the detail is in the file. jsonl can be read and written line by line, so even a million-row log never sits whole in memory (written here, read by ImportLogReader).

Writing is streamed (the handle is held for the whole run); file_put_contents(FILE_APPEND) per item would mean an open and close for every row.

Table of Contents

Constants

LEVEL_ERROR  : string = 'error'
LEVEL_INFO  : string = 'info'
LEVEL_WARNING  : string = 'warning'
PHASE_EXECUTE  : string = 'execute'
PHASE_VALIDATE  : string = 'validate'

Properties

$absolutePath  : string
$append  : bool
$errorCount  : int
$handle  : resource|null
$infoCount  : int
$phase  : string
$warningCount  : int

Methods

__construct()  : mixed
close()  : void
Closes the handle. When no row was written during the whole run, an empty file is still created, so the admin report can tell "run finished without rows" from "log does not exist".
error()  : void
Hard error: the item is not written at all.
getErrorCount()  : int
getInfoCount()  : int
getWarningCount()  : int
info()  : void
warning()  : void
Soft error: the item is written without the problematic part and marked `importIncomplete`.
getHandle()  : resource
write()  : void

Constants

Properties

Methods

__construct()

public __construct(string $absolutePath[, string $phase = self::PHASE_VALIDATE ][, bool $append = false ]) : mixed
Parameters
$absolutePath : string
$phase : string = self::PHASE_VALIDATE
$append : bool = false

true appends rows to the end of an existing log (self-heal adds "run interrupted" to the log of a crashed run); by default the log is overwritten (new run).

close()

Closes the handle. When no row was written during the whole run, an empty file is still created, so the admin report can tell "run finished without rows" from "log does not exist".

public close() : void

error()

Hard error: the item is not written at all.

public error(int $line, string|null $code, string|null $action, string $message[, string|null $key = null ][, string|null $value = null ]) : void
Parameters
$line : int
$code : string|null
$action : string|null
$message : string
$key : string|null = null
$value : string|null = null

info()

public info(int $line, string|null $code, string|null $action, string $message[, string|null $key = null ][, string|null $value = null ]) : void
Parameters
$line : int
$code : string|null
$action : string|null
$message : string
$key : string|null = null
$value : string|null = null

warning()

Soft error: the item is written without the problematic part and marked `importIncomplete`.

public warning(int $line, string|null $code, string|null $action, string $message[, string|null $key = null ][, string|null $value = null ]) : void

$value is the attempted value from the file; without it the admin would not know what to fix in the file.

Parameters
$line : int
$code : string|null
$action : string|null
$message : string
$key : string|null = null
$value : string|null = null

write()

private write(string $level, int $line, string|null $code, string|null $action, string $message, string|null $key, string|null $value) : void
Parameters
$level : string
$line : int
$code : string|null
$action : string|null
$message : string
$key : string|null
$value : string|null
On this page

Search results