Skip to content

Commit 914d4e7

Browse files
committed
fix: Add padding after timestamp only if timestamp was actually written
1 parent 5fffe00 commit 914d4e7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,18 @@ where
327327

328328
// Time.
329329

330-
self.timer
331-
.format_time(&mut event_buf)
332-
.expect("Unable to write time to buffer");
333-
write!(event_buf, " ").expect("Unable to write to buffer");
330+
{
331+
let prev_buffer_len = event_buf.len();
332+
333+
self.timer
334+
.format_time(&mut event_buf)
335+
.expect("Unable to write time to buffer");
336+
337+
// Something was written to the buffer, pad it with a space.
338+
if prev_buffer_len < event_buf.len() {
339+
write!(event_buf, " ").expect("Unable to write to buffer");
340+
}
341+
}
334342

335343
// printing the indentation
336344
let indent = ctx

0 commit comments

Comments
 (0)