aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-10-18 18:35:28 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-10-18 18:35:28 +0200
commit5d27fb85fc3d482f10aa7b5fab900beb1d4a0e92 (patch)
treec7d410e2c8700fdeff9e5b1193a6ec3a341ea1f7
parentf64ef1a6c476bcdf6212931a086e263d8d60daeb (diff)
downloadcpp-utils-5d27fb85fc3d482f10aa7b5fab900beb1d4a0e92.tar.gz
cpp-utils-5d27fb85fc3d482f10aa7b5fab900beb1d4a0e92.zip
log: replace fprintf with fwrite
-rw-r--r--log.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/log.h b/log.h
index 8bb53c6..6aca9ea 100644
--- a/log.h
+++ b/log.h
@@ -167,11 +167,11 @@ constexpr void logger<WithTimestamp, BufSize>::log(const char* fmt,
assert(pos < BufSize);
// Ensure terminated with new line and null terminator.
- assert(pos < BufSize - 1);
- m_buf[pos++] = '\0';
+ assert(pos < BufSize);
+ m_buf[pos++] = '\n';
// Write out log message.
- std::fprintf(stderr, "%s\n", m_buf);
+ std::fwrite(m_buf, pos < BufSize ? pos : BufSize, 1 /* nmemb */, stderr);
}
} // namespace logging