Replace logging with std::format
std::format is a much more modern logging solution, and gives us a lot
more flexibility, and better compile times when doing logging.
Unfortunately, given its level of compile time checks, it needs to be a
method, instead of the stream style logging we had before. This
requires a pretty substantial change. Fortunately, this change can be
largely automated, via the script included in this commit under
scripts/replace_logs.py. This is to aid people in moving their
patchsets over to the new form in the short period where old patches
will be based on the old logging. The intention is that this script
eventually goes away.
The old style logging (stream based) looked like.
BMCWEB_LOG_DEBUG << "Foo " << foo;
The new equivalent of the above would be:
BMCWEB_LOG_DEBUG("Foo {}", foo);
In the course of doing this, this also cleans up several ignored linter
errors, including macro usage, and array to pointer deconstruction.
Note, This patchset does remove the timestamp from the log message. In
practice, this was duplicated between journald and bmcweb, and there's
no need for both to exist.
One design decision of note is the addition of logPtr. Because the
compiler can't disambiguate between const char* and const MyThing*, it's
necessary to add an explicit cast to void*. This is identical to how
fmt handled it.
Tested: compiled with logging meson_option enabled, and launched bmcweb
Saw the usual logging, similar to what was present before:
```
[Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled
[Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800
[Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist
[Info src/webserver_main.cpp:59] Starting webserver on port 18080
[Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file.
[Info src/webserver_main.cpp:137] Start Hostname Monitor Service...
```
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8
diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp
index 53df1db..f36a319 100644
--- a/redfish-core/lib/led.hpp
+++ b/redfish-core/lib/led.hpp
@@ -35,7 +35,7 @@
inline void
getIndicatorLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- BMCWEB_LOG_DEBUG << "Get led groups";
+ BMCWEB_LOG_DEBUG("Get led groups");
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
"/xyz/openbmc_project/led/groups/enclosure_identify_blink",
@@ -45,8 +45,8 @@
// proceed to get enclosure_identify state.
if (ec == boost::system::errc::invalid_argument)
{
- BMCWEB_LOG_DEBUG
- << "Get identity blinking LED failed, missmatch in property type";
+ BMCWEB_LOG_DEBUG(
+ "Get identity blinking LED failed, missmatch in property type");
messages::internalError(asyncResp->res);
return;
}
@@ -67,8 +67,8 @@
const bool ledOn) {
if (ec2 == boost::system::errc::invalid_argument)
{
- BMCWEB_LOG_DEBUG
- << "Get enclosure identity led failed, missmatch in property type";
+ BMCWEB_LOG_DEBUG(
+ "Get enclosure identity led failed, missmatch in property type");
messages::internalError(asyncResp->res);
return;
}
@@ -103,7 +103,7 @@
setIndicatorLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& ledState)
{
- BMCWEB_LOG_DEBUG << "Set led groups";
+ BMCWEB_LOG_DEBUG("Set led groups");
bool ledOn = false;
bool ledBlinkng = false;
@@ -146,7 +146,7 @@
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec2);
messages::internalError(asyncResp->res);
return;
}
@@ -165,7 +165,7 @@
inline void getLocationIndicatorActive(
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- BMCWEB_LOG_DEBUG << "Get LocationIndicatorActive";
+ BMCWEB_LOG_DEBUG("Get LocationIndicatorActive");
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
"/xyz/openbmc_project/led/groups/enclosure_identify_blink",
@@ -175,8 +175,8 @@
// proceed to get enclosure_identify state.
if (ec == boost::system::errc::invalid_argument)
{
- BMCWEB_LOG_DEBUG
- << "Get identity blinking LED failed, missmatch in property type";
+ BMCWEB_LOG_DEBUG(
+ "Get identity blinking LED failed, missmatch in property type");
messages::internalError(asyncResp->res);
return;
}
@@ -197,8 +197,8 @@
const bool ledOn) {
if (ec2 == boost::system::errc::invalid_argument)
{
- BMCWEB_LOG_DEBUG
- << "Get enclosure identity led failed, missmatch in property type";
+ BMCWEB_LOG_DEBUG(
+ "Get enclosure identity led failed, missmatch in property type");
messages::internalError(asyncResp->res);
return;
}
@@ -224,7 +224,7 @@
inline void setLocationIndicatorActive(
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const bool ledState)
{
- BMCWEB_LOG_DEBUG << "Set LocationIndicatorActive";
+ BMCWEB_LOG_DEBUG("Set LocationIndicatorActive");
sdbusplus::asio::setProperty(
*crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
@@ -244,7 +244,7 @@
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec2);
messages::internalError(asyncResp->res);
return;
}