Enable bmcweb dynamic logging
Create a CLI app called "bmcweb" that can set logging levels on
"bmcwebd", the new bmcweb daemon. Create a dbus connection to set log
level using the CLI app Define the "setLogLevel" method on dbus to
control logging level in bmcwebd Add logic to move logging level from
build option to dynamic overloading
Reason: bmcweb picks up logging level as a compile flag. We want it to
be more flexible to debug errors in the field. Using the bmcweb CLI
app, we can set log levels on the bmcweb daemon during runtime.
Splitting bmcweb.
For example, to set logging level to INFO on the target:
bmcweb -l INFO
Change-Id: I7192e4d0ac7aa3a91babecc473521be27ea8acd1
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/http/logging.hpp b/http/logging.hpp
index e2b9fef..526d186 100644
--- a/http/logging.hpp
+++ b/http/logging.hpp
@@ -53,8 +53,24 @@
}
// configured bmcweb LogLevel
-constexpr crow::LogLevel bmcwebCurrentLoggingLevel =
- getLogLevelFromName(BMCWEB_LOGGING_LEVEL);
+inline crow::LogLevel& getBmcwebCurrentLoggingLevel()
+{
+ static crow::LogLevel level = getLogLevelFromName(BMCWEB_LOGGING_LEVEL);
+ return level;
+}
+
+struct FormatString
+{
+ std::string_view str;
+ std::source_location loc;
+
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ FormatString(const char* stringIn, const std::source_location& locIn =
+ std::source_location::current()) :
+ str(stringIn),
+ loc(locIn)
+ {}
+};
template <typename T>
const void* logPtr(T p)
@@ -68,7 +84,7 @@
inline void vlog(std::format_string<Args...>&& format, Args&&... args,
const std::source_location& loc) noexcept
{
- if constexpr (bmcwebCurrentLoggingLevel < level)
+ if (getBmcwebCurrentLoggingLevel() < level)
{
return;
}