AnsiTextStreamSink
TextStreamSink that colors warning-and-above lines so they stand out in an interactive terminal: yellow = warning red = error bold red = critical/alert/emergency Debug/info/notice are left uncolored — the goal is making problems jump out, not painting every line.
Colors are auto-disabled when NO_COLOR is set (see https://no-color.org) or the destination isn’t a TTY (e.g. output redirected to a file or piped into another program), so this is safe to use as a default dev-console sink without leaking escape codes into redirected output. Pass $colors explicitly to override the auto-detection.
Synopsis
Section titled “Synopsis”class AnsiTextStreamSink extends TextStreamSink
| Extends | TextStreamSink |
| Source | Logging/Sink/AnsiTextStreamSink.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(string $stream = 'php://stderr', Level $minLevel = Quiote\Logging\Level::Debug, array<string, Level> $categoryOverrides = [], mixed $streamResource = null, ?bool $colors = null): mixed
| Parameter | Type | Description |
|---|---|---|
$stream | string | |
$minLevel | Level | |
$categoryOverrides | array``<``string``, Level> | |
$streamResource | mixed | |
$colors | ?``bool |
Returns mixed
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
emit() | AbstractStreamSink | Renders the event through the subclass AnsiTextStreamSink::format() and writes it as one newline-terminated line. |
flush() | AbstractStreamSink | Flushes the underlying stream if one has been opened. |
isEnabled() | AbstractStreamSink | Whether this sink accepts an event at $level for $category. |