Add Int64 file rotation path and JSON roundtrip

This commit is contained in:
Nanaloveyuki
2026-07-05 21:31:52 +08:00
parent 93e9bd966d
commit e001315319
13 changed files with 368 additions and 23 deletions
+24
View File
@@ -2,6 +2,7 @@
pub struct FileRotation {
max_bytes : Int
max_backups : Int
native_wide_max_bytes : Int64?
}
///|
@@ -71,6 +72,29 @@ pub fn file_rotation(max_bytes : Int, max_backups? : Int = 1) -> FileRotation {
} else {
max_backups
},
native_wide_max_bytes: None,
}
}
///|
pub fn file_rotation_i64(
max_bytes : Int64,
max_backups? : Int = 1,
) -> FileRotation {
let normalized = if max_bytes <= 0L { 1L } else { max_bytes }
let clamped_max_bytes = if normalized > 2147483647L {
2147483647
} else {
normalized.to_int()
}
{
max_bytes: clamped_max_bytes,
max_backups: if max_backups <= 0 {
1
} else {
max_backups
},
native_wide_max_bytes: Some(normalized),
}
}