Skip to content

Commit bc70542

Browse files
committed
feat(main): add log rotation and append mode
1 parent 5cd6977 commit bc70542

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use tracing_subscriber::util::SubscriberInitExt;
1010
mod data;
1111
mod media;
1212
mod single_instance;
13+
mod status;
1314
mod ui;
1415
mod updater;
1516

@@ -21,10 +22,14 @@ fn main() -> anyhow::Result<()> {
2122
std::fs::create_dir_all(&data_dir).ok();
2223

2324
let log_path = data_dir.join("vleer.log");
25+
if let Ok(meta) = std::fs::metadata(&log_path)
26+
&& meta.len() > 5 * 1024 * 1024
27+
{
28+
let _ = std::fs::rename(&log_path, data_dir.join("vleer.log.old"));
29+
}
2430
let log_file = std::fs::OpenOptions::new()
2531
.create(true)
26-
.write(true)
27-
.truncate(true)
32+
.append(true)
2833
.open(&log_path)?;
2934

3035
tracing_subscriber::registry()

0 commit comments

Comments
 (0)