AbstractStreamSink
Base for sinks that write one line per event to a stream.
Handles the per-sink minimum level (+ optional per-category overrides, longest-prefix wins) and lazy stream opening. Subclasses implement AbstractStreamSink::format().
Synopsis
Section titled “Synopsis”abstract class AbstractStreamSink implements SinkInterface
| Implements | SinkInterface |
| Source | Logging/Sink/AbstractStreamSink.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(Level $minLevel = Quiote\Logging\Level::Debug, array<string, Level> $categoryOverrides = [], string $stream = 'php://stdout', resource|null $streamResource = null): mixed
An already-open writable resource (e.g. for tests), used instead of opening $stream lazily.
| Parameter | Type | Description |
|---|---|---|
$minLevel | Level | Minimum level this sink accepts by default. |
$categoryOverrides | array``<``string``, Level> | category-prefix => min level. |
$stream | string | A stream path (opened lazily, append). |
$streamResource | `resource“ | “null` |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
emit(LogEvent $event): void | Renders the event through the subclass AbstractStreamSink::format() and writes it as one newline-terminated line. |
flush(): void | Flushes the underlying stream if one has been opened. |
format(LogEvent $event): string | Render an event to a single line (no trailing newline). |
formatPlainLine(LogEvent $event): string | Shared human-readable single-line rendering used by TextStreamSink and FileSink (and, via TextStreamSink, AnsiTextStreamSink): 2026-07-01T08:02:55.123Z WARNING Quiote.Routing: no route matched /foo {rid=abc} |
formatTimestamp(float $ts): string | Format a UNIX timestamp (with microseconds) as ISO-8601 UTC with milliseconds, e.g. |
| [`handle(): resource | null`](#handle) |
isEnabled(Level $level, string $category): bool | Whether this sink accepts an event at $level for $category. |
writeLine(string $line): void |
emit()
Section titled “emit()”public function emit(LogEvent $event): void
Renders the event through the subclass AbstractStreamSink::format() and writes it as one newline-terminated line.
The stream is opened on first write when the sink was configured with a path rather than a resource. A stream that cannot be opened, or a write that fails, is silently dropped rather than allowed to break the request that was only trying to log.
| Parameter | Type | Description |
|---|---|---|
$event | LogEvent |
flush()
Section titled “flush()”public function flush(): void
Flushes the underlying stream if one has been opened.
A sink that has never emitted anything holds no handle and does nothing here; it does not open the stream just to flush it.
format()
Section titled “format()”abstract protected function format(LogEvent $event): string
Render an event to a single line (no trailing newline).
| Parameter | Type | Description |
|---|---|---|
$event | LogEvent |
Returns string
formatPlainLine()
Section titled “formatPlainLine()”protected static function formatPlainLine(LogEvent $event): string
Shared human-readable single-line rendering used by TextStreamSink and FileSink (and, via TextStreamSink, AnsiTextStreamSink): 2026-07-01T08:02:55.123Z WARNING Quiote.Routing: no route matched /foo {rid=abc}
| Parameter | Type | Description |
|---|---|---|
$event | LogEvent |
Returns string
formatTimestamp()
Section titled “formatTimestamp()”protected static function formatTimestamp(float $ts): string
Format a UNIX timestamp (with microseconds) as ISO-8601 UTC with milliseconds, e.g.
2026-07-01T08:02:55.123Z.
| Parameter | Type | Description |
|---|---|---|
$ts | float |
Returns string
handle()
Section titled “handle()”protected function handle(): resource|null
Returns resource``|``null
isEnabled()
Section titled “isEnabled()”public function isEnabled(Level $level, string $category): bool
Whether this sink accepts an event at $level for $category.
The minimum level is the longest category-prefix override that matches (exact name, or a prefix followed by a dot), falling back to the sink’s default minimum level when none matches. The resolution is memoized per exact category, so repeated calls on the hot path cost a lookup.
| Parameter | Type | Description |
|---|---|---|
$level | Level | |
$category | string |
Returns bool
writeLine()
Section titled “writeLine()”protected function writeLine(string $line): void
| Parameter | Type | Description |
|---|---|---|
$line | string |