use phosphor-logging
Migrate all instances of std::cerr and std::cout to phosphor-logging
such as lg2::error, lg2::info, lg2::debug, ...
The use of modern logging infrastructure helps with development since
additional logging levels such as `debug` and `warning` are available.
Migrating the remaining logging calls helps to make the code more
readable and uniform.
Tested: Inspection, and on Tyan S8030
Restarted EM with patch applied.
Logs appear as usual.
```
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: Supermicro PWS 920P SQ 0
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: Supermicro PWS 920P SQ 1
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: Tyan S8030 Baseboard
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: MBX 1.57 Chassis
```
`busctl tree` output appears as before.
Did a power cycle to trigger a few more log prints
```
Sep 15 13:55:14 s8030-bmc-30303035c0c1 entity-manager[23480]: power match triggered
```
Created configuration file with missing fields to trigger error print.
```
{
"Exposes": [],
"Type": "error"
}
```
```
Sep 15 13:56:58 s8030-bmc-30303035c0c1 entity-manager[23659]: Finished loading json configuration in 7938ms
Sep 15 13:56:58 s8030-bmc-30303035c0c1 entity-manager[23659]: configuration file missing probe:
{"Exposes":[],"Type":"error"}
Sep 15 13:56:59 s8030-bmc-30303035c0c1 entity-manager[23659]: configuration file missing probe:
{"Exposes":[],"Type":"error"}
```
Change-Id: I3452f983c9c14cd02ab9b56451c4b3e4a13c3979
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/perform_probe.cpp b/src/entity_manager/perform_probe.cpp
index 50943c7..f398860 100644
--- a/src/entity_manager/perform_probe.cpp
+++ b/src/entity_manager/perform_probe.cpp
@@ -8,7 +8,6 @@
#include <boost/algorithm/string/replace.hpp>
#include <phosphor-logging/lg2.hpp>
-#include <iostream>
#include <regex>
#include <utility>
@@ -110,8 +109,8 @@
{
if (!std::regex_search(probe, match, command))
{
- std::cerr
- << "found probe syntax error " << probe << "\n";
+ lg2::error("found probe syntax error {JSON}", "JSON",
+ probe);
return false;
}
std::string commandStr = *(match.begin() + 1);
@@ -132,7 +131,7 @@
{
if (!std::regex_search(probe, match, command))
{
- std::cerr << "dbus probe syntax error " << probe << "\n";
+ lg2::error("dbus probe syntax error {JSON}", "JSON", probe);
return false;
}
std::string commandStr = *(match.begin() + 1);
@@ -142,7 +141,8 @@
auto json = nlohmann::json::parse(commandStr, nullptr, false, true);
if (json.is_discarded())
{
- std::cerr << "dbus command syntax error " << commandStr << "\n";
+ lg2::error("dbus command syntax error {STR}", "STR",
+ commandStr);
return false;
}
// we can match any (string, variant) property. (string, string)