newline delimit audit logs

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-10-16 21:41:26 -05:00
parent 9d883b5851
commit 56c7391cd5
No known key found for this signature in database

View file

@ -5,6 +5,7 @@ use reqwest::Url;
use serde::Serialize; use serde::Serialize;
use std::collections::HashSet; use std::collections::HashSet;
use std::fs::{File, OpenOptions}; use std::fs::{File, OpenOptions};
use std::io::Write;
use std::sync::atomic::AtomicU32; use std::sync::atomic::AtomicU32;
use std::{collections::HashMap, fmt::Debug, ops::DerefMut, path::PathBuf, sync::Arc}; use std::{collections::HashMap, fmt::Debug, ops::DerefMut, path::PathBuf, sync::Arc};
use tokio::sync::{Mutex, RwLock}; use tokio::sync::{Mutex, RwLock};
@ -117,7 +118,6 @@ impl AuditState {
let file = OpenOptions::new() let file = OpenOptions::new()
.create(true) .create(true)
.append(true) .append(true)
.open(self.options.output.join(&full_name))?; .open(self.options.output.join(&full_name))?;
@ -149,6 +149,7 @@ impl AuditState {
let mut f = file.lock().await; let mut f = file.lock().await;
serde_json::to_writer(f.deref_mut(), &item)?; serde_json::to_writer(f.deref_mut(), &item)?;
write!(f.deref_mut(), "\n\n")?;
let meta = f.get_ref().metadata()?; let meta = f.get_ref().metadata()?;
@ -173,6 +174,7 @@ impl AuditState {
let file = read.get(name).unwrap(); let file = read.get(name).unwrap();
serde_json::to_writer(file.lock().await.deref_mut(), &item)?; serde_json::to_writer(file.lock().await.deref_mut(), &item)?;
write!(file.lock().await.deref_mut(), "\n\n")?;
} }
Ok(()) Ok(())