phrocker commented on a change in pull request #596: MINIFICPP-925 - Fix
TailFile hang on long lines
URL: https://github.com/apache/nifi-minifi-cpp/pull/596#discussion_r296837038
##########
File path: extensions/standard-processors/processors/LogAttribute.cpp
##########
@@ -137,33 +137,32 @@ void LogAttribute::onTrigger(const
std::shared_ptr<core::ProcessContext> &contex
message << "\n" << "Payload:" << "\n";
ReadCallback callback(flow->getSize());
session->read(flow, &callback);
- for (unsigned int i = 0, j = 0; i < callback.read_size_; i++) {
- message << std::hex << callback.buffer_[i];
- j++;
- if (j == 80) {
- message << '\n';
- j = 0;
- }
+
+ auto payload_hex = utils::StringUtils::to_hex(callback.buffer_.data(),
callback.buffer_.size());
+ for (size_t i = 0; i < payload_hex.size(); i += 80) {
+ message << payload_hex.substr(i, 80) << '\n';
}
+ } else {
+ message << "\n";
}
- message << "\n" << dashLine;
+ message << dashLine;
std::string output = message.str();
switch (level) {
case LogAttrLevelInfo:
- logger_->log_info("%s", output);
Review comment:
let's revert these. and I don't see their purpose. We want to stray way from
people using .c_str() in log statements, too, as a general guideline. This
creates a proof of concept that differs from the style in the code base.
----------------------------------------------------------------
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