Append a boot separator line with timestamp to an append-mode log file.
(path: &std::path::Path)
| 1080 | |
| 1081 | /// Append a boot separator line with timestamp to an append-mode log file. |
| 1082 | fn append_boot_separator(path: &std::path::Path) { |
| 1083 | use std::io::Write; |
| 1084 | if !path.exists() { |
| 1085 | return; |
| 1086 | } |
| 1087 | let Ok(mut file) = std::fs::OpenOptions::new().append(true).open(path) else { |
| 1088 | return; |
| 1089 | }; |
| 1090 | let timestamp = humantime::format_rfc3339_seconds(std::time::SystemTime::now()); |
| 1091 | let _ = writeln!(file, "\n===== boot @ {timestamp} =====\n"); |
| 1092 | } |
| 1093 | |
| 1094 | /// Append current serial.log into serial.history.log with a boot separator, |
| 1095 | /// then truncate history if it exceeds `max_bytes`. |