2.6 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| runtime-sink-file-close | api | runtime | 20260707 | Close the file sink behind a RuntimeSink when one is present, with queued-file success tied to safe drain-flush-close behavior. |
|
Runtime-sink-file-close
Close the file sink behind a RuntimeSink. This helper is the direct file-specific runtime close surface for code that owns a sink value instead of a ConfiguredLogger.
Interface
pub fn RuntimeSink::file_close(self : RuntimeSink) -> Bool {
input
self : RuntimeSink- Runtime sink whose file sink should be closed.
output
Bool- Whether the file-specific close path succeeded.
Explanation
Detailed rules explaining key parameters and behaviors
- Plain
Fileruntime variants forward directly toFileSink::close(). QueuedFileruntime variants first drain the queue, then flush the wrapped file sink, then close it.- For
QueuedFile, the returnedBoolistrueonly when that whole path succeeds and no new write, flush, or rotation failures are observed during the drain-flush-close step. - Non-file runtime variants return
false. - After a file-backed runtime sink has already cleared its handle, later
file_close()calls returnfalse.
How to Use
Here are some specific examples provided.
When Need Direct File-specific Runtime Teardown
When code holds a file-backed RuntimeSink directly and should close its file handle explicitly:
ignore(sink.file_close())
In this example, file teardown happens through the runtime sink itself.
When Need A File-specific Close Result
When application code wants the direct file close outcome:
let closed = sink.file_close()
In this example, the result describes the file-specific close path rather than generic sink close behavior.
Error Case
e.g.:
-
If the runtime sink is not file-backed, the method returns
false. -
If the file handle was already closed earlier through this runtime sink or another facade sharing the same underlying file-backed state, the method returns
false. -
If callers only need generic sink teardown,
close()is the broader API. -
On queued file sinks,
truestill does not mean a stronger durability contract than the current backend can report; it means the safe drain-flush-close path completed without a newly observed file failure.
Notes
-
Prefer this helper when direct runtime code specifically cares about file-backed shutdown.
-
Generic
close()now uses the same safe queued-file teardown path.