martinzink commented on code in PR #1670:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1670#discussion_r1339867965
##########
extensions/aws/utils/AWSSdkLogger.cpp:
##########
@@ -21,51 +21,45 @@
#include "aws/core/utils/logging/LogLevel.h"
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace aws {
-namespace utils {
+namespace org::apache::nifi::minifi::aws::utils {
-Aws::Utils::Logging::LogLevel AWSSdkLogger::GetLogLevel() const {
- if (logger_->should_log(minifi::core::logging::LOG_LEVEL::trace))
- return Aws::Utils::Logging::LogLevel::Trace;
- if (logger_->should_log(minifi::core::logging::LOG_LEVEL::debug))
- return Aws::Utils::Logging::LogLevel::Debug;
- if (logger_->should_log(minifi::core::logging::LOG_LEVEL::info))
- return Aws::Utils::Logging::LogLevel::Info;
- if (logger_->should_log(minifi::core::logging::LOG_LEVEL::warn))
- return Aws::Utils::Logging::LogLevel::Warn;
- if (logger_->should_log(minifi::core::logging::LOG_LEVEL::err))
- return Aws::Utils::Logging::LogLevel::Error;
- if (logger_->should_log(minifi::core::logging::LOG_LEVEL::critical))
- return Aws::Utils::Logging::LogLevel::Fatal;
- return Aws::Utils::Logging::LogLevel::Off;
+namespace {
+Aws::Utils::Logging::LogLevel mapToAwsLevels(core::logging::LOG_LEVEL level) {
+ switch (level) {
+ case core::logging::trace: return Aws::Utils::Logging::LogLevel::Trace;
+ case core::logging::debug: return Aws::Utils::Logging::LogLevel::Debug;
+ case core::logging::info: return Aws::Utils::Logging::LogLevel::Info;
+ case core::logging::warn: return Aws::Utils::Logging::LogLevel::Warn;
+ case core::logging::err: return Aws::Utils::Logging::LogLevel::Error;
+ case core::logging::critical: return Aws::Utils::Logging::LogLevel::Fatal;
+ case core::logging::off: return Aws::Utils::Logging::LogLevel::Off;
+ default:
+ throw std::invalid_argument(fmt::format("Invalid LOG_LEVEL {}",
magic_enum::enum_underlying(level)));
+ }
}
-void AWSSdkLogger::Log(Aws::Utils::Logging::LogLevel log_level, const char*
tag, const char* format_str, ...) { // NOLINT(cert-dcl50-cpp)
- switch (log_level) {
- case Aws::Utils::Logging::LogLevel::Trace:
- logger_->log_trace("[%s] %s", tag, format_str);
- break;
- case Aws::Utils::Logging::LogLevel::Debug:
- logger_->log_debug("[%s] %s", tag, format_str);
- break;
- case Aws::Utils::Logging::LogLevel::Info:
- logger_->log_info("[%s] %s", tag, format_str);
- break;
- case Aws::Utils::Logging::LogLevel::Warn:
- logger_->log_warn("[%s] %s", tag, format_str);
- break;
- case Aws::Utils::Logging::LogLevel::Error:
- case Aws::Utils::Logging::LogLevel::Fatal:
- logger_->log_error("[%s] %s", tag, format_str);
- break;
+core::logging::LOG_LEVEL mapFromAwsLevels(Aws::Utils::Logging::LogLevel level)
{
+ switch (level) {
+ case Aws::Utils::Logging::LogLevel::Off: return core::logging::off;
+ case Aws::Utils::Logging::LogLevel::Fatal: return core::logging::critical;
+ case Aws::Utils::Logging::LogLevel::Error:return core::logging::err;
+ case Aws::Utils::Logging::LogLevel::Warn: return core::logging::warn;
+ case Aws::Utils::Logging::LogLevel::Info: return core::logging::info;
+ case Aws::Utils::Logging::LogLevel::Debug: return core::logging::debug;
+ case Aws::Utils::Logging::LogLevel::Trace: return core::logging::trace;
default:
- break;
+ throw std::invalid_argument(fmt::format("Invalid
Aws::Utils::Logging::LogLevel {}", magic_enum::enum_underlying(level)));
Review Comment:
Good idea, I've fixed it in
https://github.com/apache/nifi-minifi-cpp/pull/1670/commits/baa9e12b8ec08c0b13209fdaef708448d2399c79
--
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]