FileSink class

Appends formatted events to a single file.

Events are written through a buffered IOSink. Writes are fire-and- forget from the caller's point of view; the sink enqueues them on the underlying sink and flushes on flush / close. Errors from the underlying file handle are swallowed to honor the LogSink contract.

Exported via package:steno/io.dart, not the main library, because dart:io is not available on web.

Implemented types

Constructors

FileSink({required String path, LogFormatter? formatter, bool append = true})
Creates a file sink. Opens the file lazily on first write.

Properties

append → bool
Append to the file if it exists (true, default) or truncate it.
final
formatter → LogFormatter
Formatter for lines written to the file. Defaults to JSON.
final
hashCode → int
The hash code for this object.
no setterinherited
name → String
Short diagnostic name for this sink (used by LoggerHealth).
no setteroverride
path → String
Path of the file being written to.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → Future<void>
Releases any resources held by this sink. After close returns, the sink must not accept any more events.
override
flush({Duration timeout = const Duration(seconds: 2)}) → Future<void>
Flushes any pending buffered events to the underlying transport. Returns a future that completes when all buffered events have been written, or when timeout elapses, whichever is first.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
write(LogEvent event) → void
Consumes event. Must not throw. May be asynchronous internally.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited