FileSink
Plain-text sink that appends one line per event to a file on disk, creating the parent directory if it doesn’t exist yet (AbstractStreamSink’s lazy fopen() would otherwise fail silently against a missing directory).
Same line format as TextStreamSink — deliberately never colorized, since a log file is read by more than terminals (tail | grep, log shippers, etc.) and ANSI escape codes would just be noise there. For a colorized terminal sink use AnsiTextStreamSink.
Synopsis
Section titled “Synopsis”final class FileSink extends AbstractStreamSink
| Extends | AbstractStreamSink |
| Source | Logging/Sink/FileSink.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(string $path, Level $minLevel = Quiote\Logging\Level::Debug, array<string, Level> $categoryOverrides = [], resource|null $streamResource = null): mixed
Pre-opened resource, for tests — when supplied, $path is never touched and no directory is created.
| Parameter | Type | Description |
|---|---|---|
$path | string | Filesystem path to append to. |
$minLevel | Level | |
$categoryOverrides | array``<``string``, Level> | |
$streamResource | `resource“ | “null` |
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 FileSink::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. |