logging: switch to lg2
After switching to C++20, it is recommended to use `phosphor::lg2`
to format log, and the correct `CODE_LINE` and `CODE_FUNC` values
can be used in log tracking.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: If137ba802d0169fe6cd6c9ab8286d5f8cda31668
diff --git a/utility.hpp b/utility.hpp
index 007ad37..89857fd 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -3,7 +3,7 @@
#include <gpioplus/chip.hpp>
#include <gpioplus/handle.hpp>
#include <gpioplus/utility/aspeed.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <exception>
#include <string>
@@ -28,9 +28,7 @@
}
catch (const std::logic_error& e)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in gpioplus - nameToOffset",
- phosphor::logging::entry("ERROR=%s", e.what()));
+ lg2::error("Error in gpioplus - nameToOffset: {ERROR}", "ERROR", e);
return false;
}
@@ -48,9 +46,7 @@
}
catch (const std::exception& e)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in gpioplus",
- phosphor::logging::entry("ERROR=%s", e.what()));
+ lg2::error("Error in gpioplus: {ERROR}", "ERROR", e);
return false;
}