szaszm commented on code in PR #1670:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1670#discussion_r1342557733
##########
extensions/http-curl/protocols/RESTSender.cpp:
##########
@@ -183,12 +183,12 @@ C2Payload RESTSender::sendPayload(const std::string& url,
const Direction direct
const bool clientError = 400 <= respCode && respCode < 500;
const bool serverError = 500 <= respCode && respCode < 600;
if (clientError || serverError) {
- logger_->log_error("Error response code '" "%" PRId64 "' from '%s'",
respCode, url);
+ logger_->log_error("Error response code '{}' from '{}'", respCode, url);
} else {
- logger_->log_debug("Response code '" "%" PRId64 "' from '%s'", respCode,
url);
+ logger_->log_debug("Response code '{}' from '{}'", respCode, url);
}
const auto response_body_bytes =
gsl::make_span(client.getResponseBody()).as_span<const std::byte>();
- logger_->log_trace("Received response: \"%s\"", [&] {return
utils::StringUtils::escapeUnprintableBytes(response_body_bytes);});
+ logger_->log_trace("Received response: {}", [&] { return
utils::StringUtils::escapeUnprintableBytes(response_body_bytes);});
Review Comment:
I'd restore the quotes around the printed response
##########
libminifi/include/core/logging/Logger.h:
##########
@@ -112,19 +62,42 @@ enum LOG_LEVEL {
off = 6
};
+inline spdlog::level::level_enum mapToSpdLogLevel(LOG_LEVEL level) {
+ switch (level) {
+ case trace: return spdlog::level::trace;
+ case debug: return spdlog::level::debug;
+ case info: return spdlog::level::info;
+ case warn: return spdlog::level::warn;
+ case err: return spdlog::level::err;
+ case critical: return spdlog::level::critical;
+ case off: return spdlog::level::off;
+ }
+ throw std::invalid_argument(fmt::format("Invalid LOG_LEVEL {}",
magic_enum::enum_underlying(level)));
+}
+
+inline LOG_LEVEL mapFromSpdLogLevel(spdlog::level::level_enum level) {
+ switch (level) {
+ case spdlog::level::trace: return LOG_LEVEL::trace;
+ case spdlog::level::debug: return LOG_LEVEL::debug;
+ case spdlog::level::info: return LOG_LEVEL::info;
+ case spdlog::level::warn: return LOG_LEVEL::warn;
+ case spdlog::level::err: return LOG_LEVEL::err;
+ case spdlog::level::critical: return LOG_LEVEL::critical;
Review Comment:
I'd consider removing the critical level from our own log levels, and just
map it to error. We're not using it anywhere as far as I'm aware.
##########
libminifi/src/core/ProcessSession.cpp:
##########
@@ -548,10 +548,10 @@ void ProcessSession::import(std::string source, const
std::shared_ptr<FlowFile>
throw Exception(FILE_OPERATION_EXCEPTION, "File Import Error");
}
} catch (const std::exception& exception) {
- logger_->log_debug("Caught Exception during ProcessSession::import, type:
%s, what: %s", exception.what());
+ logger_->log_debug("Caught Exception during ProcessSession::import, type:
{}, what: {}", typeid(exception).name(), exception.what());
Review Comment:
good catch
##########
libminifi/src/core/flow/StructuredConnectionParser.cpp:
##########
@@ -85,10 +85,10 @@ uint64_t StructuredConnectionParser::getWorkQueueDataSize()
const {
std::string max_work_queue_str =
max_work_queue_data_size_node.getIntegerAsString().value();
uint64_t max_work_queue_data_size = 0;
if (core::Property::StringToInt(max_work_queue_str,
max_work_queue_data_size)) {
- logger_->log_debug("Setting %" PRIu64 "as the max as the max queue data
size.", max_work_queue_data_size);
+ logger_->log_debug("Setting {}as the max as the max queue data size.",
max_work_queue_data_size);
Review Comment:
```suggestion
logger_->log_debug("Setting {} as the max as the max queue data
size.", max_work_queue_data_size);
```
##########
libminifi/src/io/FileStream.cpp:
##########
@@ -78,11 +78,11 @@ FileStream::FileStream(std::filesystem::path path, uint32_t
offset, bool write_e
seekToEndOfFile(FILE_OPENING_ERROR_MSG);
auto len = file_stream_->tellg();
if (len == std::streampos(-1))
- core::logging::LOG_ERROR(logger_) << FILE_OPENING_ERROR_MSG <<
TELLG_CALL_ERROR_MSG;
+ logger_->log_error("{}{}", FILE_OPENING_ERROR_MSG, TELLG_CALL_ERROR_MSG);
length_ = len > 0 ? gsl::narrow<size_t>(len) : 0;
FileStream::seek(offset_);
} else {
- core::logging::LOG_ERROR(logger_) << FILE_OPENING_ERROR_MSG <<
path_.string() << " " << strerror(errno);
+ logger_->log_error("{}{}{}", FILE_OPENING_ERROR_MSG, path_,
strerror(errno));
Review Comment:
```suggestion
logger_->log_error("{}{} {}", FILE_OPENING_ERROR_MSG, path_,
strerror(errno));
```
--
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]