lordgamez commented on code in PR #1920:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1920#discussion_r1963270369
##########
libminifi/include/core/logging/LoggerBase.h:
##########
@@ -80,6 +80,36 @@ inline LOG_LEVEL
mapFromSpdLogLevel(spdlog::level::level_enum level) {
throw std::invalid_argument(fmt::format("Invalid spdlog::level::level_enum
{}", magic_enum::enum_underlying(level)));
}
+inline std::string mapLogLevelToString(LOG_LEVEL level) {
+ switch (level) {
+ case trace: return "TRACE";
+ case debug: return "DEBUG";
+ case info: return "INFO";
+ case warn: return "WARN";
+ case err: return "ERROR";
+ case critical: return "CRITICAL";
+ case off: return "OFF";
+ }
+ throw std::invalid_argument(fmt::format("Invalid LOG_LEVEL {}",
magic_enum::enum_underlying(level)));
+}
+
+inline LOG_LEVEL mapStringToLogLevel(const std::string& level_str) {
+ if (level_str == "TRACE") {
+ return trace;
+ } else if (level_str == "DEBUG") {
+ return debug;
+ } else if (level_str == "INFO") {
+ return info;
+ } else if (level_str == "WARN") {
+ return warn;
+ } else if (level_str == "ERROR") {
+ return err;
+ } else if (level_str == "CRITICAL") {
+ return critical;
+ }
+ throw std::invalid_argument(fmt::format("Invalid LOG_LEVEL {}", level_str));
+}
Review Comment:
As I checked LogUtils.h only contains mappings for the `enum class
LogLevelOption`, but not for the `enum LOG_LEVEL`. As I remember we had a brief
discussion about standardizing log level representation last year as we have
different log level representations in different classes all around the
project, but that should be done in a separate PR.
--
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]