Fix empty line logging.
This commit is contained in:
parent
790ce8aee1
commit
0133bec11d
|
@ -126,9 +126,9 @@ class Logger {
|
||||||
std::snprintf(prefix + 3, sizeof(prefix) - 3, "%08" PRIX32 " ",
|
std::snprintf(prefix + 3, sizeof(prefix) - 3, "%08" PRIX32 " ",
|
||||||
line.thread_id);
|
line.thread_id);
|
||||||
fwrite(prefix, 1, sizeof(prefix) - 1, file_);
|
fwrite(prefix, 1, sizeof(prefix) - 1, file_);
|
||||||
|
if (line.buffer_length) {
|
||||||
// Get access to the line data - which may be split in the ring buffer -
|
// Get access to the line data - which may be split in the ring buffer
|
||||||
// and write it out in parts.
|
// - and write it out in parts.
|
||||||
auto line_range = ring_buffer_.BeginRead(line.buffer_length);
|
auto line_range = ring_buffer_.BeginRead(line.buffer_length);
|
||||||
fwrite(line_range.first, 1, line_range.first_length, file_);
|
fwrite(line_range.first, 1, line_range.first_length, file_);
|
||||||
if (line_range.second_length) {
|
if (line_range.second_length) {
|
||||||
|
@ -143,6 +143,10 @@ class Logger {
|
||||||
fwrite(suffix, 1, sizeof(suffix), file_);
|
fwrite(suffix, 1, sizeof(suffix), file_);
|
||||||
}
|
}
|
||||||
ring_buffer_.EndRead(std::move(line_range));
|
ring_buffer_.EndRead(std::move(line_range));
|
||||||
|
} else {
|
||||||
|
const char suffix[1] = {'\n'};
|
||||||
|
fwrite(suffix, 1, sizeof(suffix), file_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mutex_.unlock();
|
mutex_.unlock();
|
||||||
if (did_write) {
|
if (did_write) {
|
||||||
|
|
Loading…
Reference in New Issue