phasync
Console / log

Method

Console::log

Writes a log line, in one format everywhere.

Description#

public Console::log(
    string $level,
    Stringable|string $message,
    array $context = [],
    string $source = ''
): void

The line has the local time to hundredths of a second, $source when given, the level from warning up, and the message. {key} placeholders take the values in $context (underlined when styled). Nothing is parsed as markup, and control characters are escaped, so the line shows what was logged and can't reach a terminal as escape sequences. A line that can't be written (a full disk, a reader gone) is lost silently: logging never throws.

2026-09-30 08:02:12.43 3 warning   disk /var is full

Parameters#

$level string
A PSR-3 level: debug, info, notice, warning, error, critical, alert or emergency
$message Stringable|string
$context array = []
$source string = ''