Add file state JSON export helpers

This commit is contained in:
Nanaloveyuki
2026-05-10 13:05:06 +08:00
parent 41c9ca3eb8
commit d209b7d618
7 changed files with 220 additions and 23 deletions
+24
View File
@@ -74,6 +74,30 @@ pub struct FileSinkState {
rotation_failures : Int
}
pub fn FileSinkState::new(
path : String,
available~ : Bool = false,
append~ : Bool = true,
auto_flush~ : Bool = true,
rotation~ : FileRotation? = None,
open_failures~ : Int = 0,
write_failures~ : Int = 0,
flush_failures~ : Int = 0,
rotation_failures~ : Int = 0,
) -> FileSinkState {
{
path,
available,
append,
auto_flush,
rotation,
open_failures,
write_failures,
flush_failures,
rotation_failures,
}
}
pub fn file_rotation(max_bytes : Int, max_backups~ : Int = 1) -> FileRotation {
{
max_bytes: if max_bytes <= 0 { 1 } else { max_bytes },