Skip to content

Commit

Permalink
FileRotate: Do not rotate in the middle of a line
Browse files Browse the repository at this point in the history
  • Loading branch information
hillu committed Dec 13, 2024
1 parent 4070983 commit 2997ea1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Write for FileRotate {
let mut f = self.file.as_ref().unwrap();
let sz = f.write(buf)?;
self.offset += sz as u64;
if self.offset > self.filesize && self.filesize != 0 {
if self.offset > self.filesize && self.filesize != 0 && buf.last() == Some(&b'\n') {
f.sync_all()?;
self.rotate()?;
}
Expand Down

0 comments on commit 2997ea1

Please sign in to comment.