optimize newline in logs

Signed-off-by: Valentyn Faychuk <valy@detee.ltd>
This commit is contained in:
Valentyn Faychuk 2024-12-09 16:16:28 +02:00
parent 4d93229f19
commit b8079b0981
Signed by: valy
GPG Key ID: F1AB995E20FEADC5
2 changed files with 1 additions and 2 deletions

@ -36,7 +36,7 @@ impl NodeInfo {
pub fn log(&self, ip: &IP) {
let json = format!("{{\"ip\":\"{}\",", ip) + &self.to_json()[1..];
if let Err(e) = Logfile::append(LOG_PATH, &format!("{}: {}", ip, &json)) {
if let Err(e) = Logfile::append(LOG_PATH, &format!("{}: {}\n", ip, &json)) {
println!("Could not log node info: {:?}", e);
}
}

@ -11,7 +11,6 @@ impl Logfile {
pub fn append(path: &str, msg: &str) -> Result<(), Box<dyn std::error::Error>> {
let mut file = std::fs::OpenOptions::new().create(true).append(true).open(path)?;
file.write_all(msg.as_bytes())?;
file.write_all(b"\n")?;
Ok(())
}
}