Add explicit configured file flush and close helpers

This commit is contained in:
Nanaloveyuki
2026-05-10 12:31:00 +08:00
parent 7f4aa199ea
commit 12730fded8
6 changed files with 76 additions and 3 deletions
+30
View File
@@ -231,6 +231,28 @@ pub fn RuntimeSink::file_reopen(self : RuntimeSink, append~ : Bool? = None) -> B
}
}
pub fn RuntimeSink::file_flush(self : RuntimeSink) -> Bool {
match self {
File(sink) => sink.flush()
QueuedFile(sink) => {
ignore(sink.flush())
sink.sink.flush()
}
_ => false
}
}
pub fn RuntimeSink::file_close(self : RuntimeSink) -> Bool {
match self {
File(sink) => sink.close()
QueuedFile(sink) => {
ignore(sink.flush())
sink.sink.close()
}
_ => false
}
}
pub fn RuntimeSink::file_open_failures(self : RuntimeSink) -> Int {
match self {
File(sink) => sink.open_failures()
@@ -293,6 +315,14 @@ pub fn ConfiguredLogger::file_reopen(self : ConfiguredLogger, append~ : Bool? =
self.sink.file_reopen(append=append)
}
pub fn ConfiguredLogger::file_flush(self : ConfiguredLogger) -> Bool {
self.sink.file_flush()
}
pub fn ConfiguredLogger::file_close(self : ConfiguredLogger) -> Bool {
self.sink.file_close()
}
pub fn ConfiguredLogger::file_open_failures(self : ConfiguredLogger) -> Int {
self.sink.file_open_failures()
}