fgerlits commented on code in PR #1862:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1862#discussion_r1746614775
##########
extensions/aws/utils/AWSSdkLogger.cpp:
##########
@@ -60,11 +62,36 @@ Aws::Utils::Logging::LogLevel AWSSdkLogger::GetLogLevel()
const {
}
void AWSSdkLogger::Log(Aws::Utils::Logging::LogLevel log_level, const char*
tag, const char* format_str, ...) { // NOLINT(cert-dcl50-cpp)
- logger_->log_with_level(mapFromAwsLevels(log_level), "[{}] {}", tag,
format_str);
+ va_list args;
+ va_start(args, format_str);
+ vaLog(log_level, tag, format_str, args);
+ va_end(args);
+}
+
+void AWSSdkLogger::vaLog(Aws::Utils::Logging::LogLevel log_level, const char*
tag, const char* format_str, va_list args) {
+ va_list args_copy;
+ va_copy(args_copy, args);
+ const int buffer_size = std::vsnprintf(nullptr, 0, format_str, args_copy) +
1; // +1 for the terminating \0 character
+ va_end(args_copy);
+
+ std::vector<char> buffer(buffer_size);
+
+ const int length = std::vsnprintf(buffer.data(), buffer_size, format_str,
args);
+ if (length < 0) {
+ logger_->log_error("A log line from aws-sdk-cpp could not be processed:
[{}] {}", tag, format_str);
+ return;
+ }
+ gsl_Expects(length <= buffer_size);
Review Comment:
fixed in 7e46fce84405668f8fdfa5e323bae8f71fbab858
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]