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: I151fc489a93ec7f513411aea2f0b61829bc808f6
diff --git a/snmp_main.cpp b/snmp_main.cpp
index 0ae1eef..be4bea1 100644
--- a/snmp_main.cpp
+++ b/snmp_main.cpp
@@ -2,7 +2,7 @@
#include "snmp_conf_manager.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
@@ -21,15 +21,13 @@
int main(int /*argc*/, char** /*argv[]*/)
{
- using namespace phosphor::logging;
-
auto bus = sdbusplus::bus::new_default();
sd_event* event = nullptr;
auto r = sd_event_default(&event);
if (r < 0)
{
- log<level::ERR>("Error creating a default sd_event handler");
+ lg2::error("Error creating a default sd_event handler: {RC}", "RC", r);
return r;
}