szaszm commented on a change in pull request #744: MINIFICPP-1171 - Fix "%ll"
format strings in log lines
URL: https://github.com/apache/nifi-minifi-cpp/pull/744#discussion_r387660534
##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.cpp
##########
@@ -623,7 +624,7 @@ int ConsumeWindowsEventLog::processQueue(const
std::shared_ptr<core::ProcessSess
auto before_time = std::chrono::high_resolution_clock::now();
utils::ScopeGuard timeGuard([&](){
- logger_->log_debug("processQueue processed %d Events in %llu ms",
+ logger_->log_debug("processQueue processed %d Events in %" PRIu64 " ms",
Review comment:
chrono durations are sadly not a good fit with printf-style format strings.
The standard doesn't specify the return type of
`std::chrono::milliseconds::count`, only that it's a signed integer type of at
least 45 bits.
I recommend wrapping the return value in `int64_t{ ... }` and using `PRId64`
as a format specifier. With list-initialization, we get a compiler error if a
narrowing conversion would be necessary to convert the return value to
`int64_t` and until then we can assume that we're safe and don't lose any data.
This applies to both occurences of printing durations.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services