netipmid: replace std::cerr with phosphor::logging calls
This is part of a cleanup and standardization effort of code to get
existing code up to date.
Change-Id: I0c982ef8d7afa2f56a9cd204bb8ac3112769641c
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/command/channel_auth.cpp b/command/channel_auth.cpp
index 1ad1472..1b5b604 100644
--- a/command/channel_auth.cpp
+++ b/command/channel_auth.cpp
@@ -2,8 +2,6 @@
#include <host-ipmid/ipmid-api.h>
-#include <iostream>
-
namespace command
{
diff --git a/command/guid.cpp b/command/guid.cpp
index 8cd95a6..3751d64 100644
--- a/command/guid.cpp
+++ b/command/guid.cpp
@@ -3,10 +3,12 @@
#include <host-ipmid/ipmid-api.h>
#include <mapper.h>
-#include <iostream>
+#include <phosphor-logging/log.hpp>
#include <sstream>
#include <string>
+using namespace phosphor::logging;
+
namespace cache
{
@@ -42,8 +44,9 @@
int rc = mapper_get_service(bus, guidObjPath, &busname);
if (rc < 0)
{
- std::cerr << "Failed to get " << guidObjPath
- << " bus name: " << strerror(-rc) << "\n";
+ log<level::ERR>("Failed to get bus name",
+ entry("PATH=%s", guidObjPath),
+ entry("ERROR=%s", strerror(-rc)));
break;
}
@@ -51,14 +54,16 @@
&error, &reply, "ss", chassisIntf, "uuid");
if (rc < 0)
{
- std::cerr << "Failed to call Get Method:" << strerror(-rc) << "\n";
+ log<level::ERR>("Failed to call Get Method",
+ entry("ERROR=%s", strerror(-rc)));
break;
}
rc = sd_bus_message_read(reply, "v", "s", &uuid);
if (rc < 0 || uuid == NULL)
{
- std::cerr << "Failed to get a response:" << strerror(-rc) << "\n";
+ log<level::ERR>("Failed to get a response",
+ entry("ERROR=%s", strerror(-rc)));
break;
}
diff --git a/command/open_session.cpp b/command/open_session.cpp
index b48b7e9..51da9e1 100644
--- a/command/open_session.cpp
+++ b/command/open_session.cpp
@@ -4,7 +4,9 @@
#include "endian.hpp"
#include "main.hpp"
-#include <iostream>
+#include <phosphor-logging/log.hpp>
+
+using namespace phosphor::logging;
namespace command
{
@@ -62,10 +64,10 @@
}
catch (std::exception& e)
{
- std::cerr << e.what() << "\n";
response->status_code =
static_cast<uint8_t>(RAKP_ReturnCode::INSUFFICIENT_RESOURCE);
- std::cerr << "openSession : Problem opening a session\n";
+ log<level::ERR>("openSession : Problem opening a session",
+ entry("EXCEPTION=%s", e.what()));
return outPayload;
}
diff --git a/command/rakp12.cpp b/command/rakp12.cpp
index cd7dd68..594a8fe 100644
--- a/command/rakp12.cpp
+++ b/command/rakp12.cpp
@@ -10,10 +10,12 @@
#include <algorithm>
#include <cstring>
#include <iomanip>
-#include <iostream>
+#include <phosphor-logging/log.hpp>
#include <user_channel/channel_layer.hpp>
#include <user_channel/user_layer.hpp>
+using namespace phosphor::logging;
+
namespace command
{
@@ -28,7 +30,7 @@
if (endian::from_ipmi(request->managedSystemSessionID) ==
session::SESSION_ZERO)
{
- std::cerr << "RAKP12: BMC invalid Session ID\n";
+ log<level::INFO>("RAKP12: BMC invalid Session ID");
response->rmcpStatusCode =
static_cast<uint8_t>(RAKP_ReturnCode::INVALID_SESSION_ID);
return outPayload;
@@ -43,7 +45,8 @@
}
catch (std::exception& e)
{
- std::cerr << e.what() << "\n";
+ log<level::ERR>("RAKP12 : session not found",
+ entry("EXCEPTION=%s", e.what()));
response->rmcpStatusCode =
static_cast<uint8_t>(RAKP_ReturnCode::INVALID_SESSION_ID);
return outPayload;
@@ -197,8 +200,8 @@
((request->req_max_privilege_level & session::reqMaxPrivMask) >
userAccess.privilege))
{
- std::cerr
- << "Username/Privilege lookup failed for requested privilege\n";
+ log<level::INFO>(
+ "Username/Privilege lookup failed for requested privilege");
response->rmcpStatusCode =
static_cast<uint8_t>(RAKP_ReturnCode::UNAUTH_NAME);
return outPayload;
diff --git a/command/rakp34.cpp b/command/rakp34.cpp
index a89e750..10c67fa 100644
--- a/command/rakp34.cpp
+++ b/command/rakp34.cpp
@@ -8,7 +8,9 @@
#include <algorithm>
#include <cstring>
-#include <iostream>
+#include <phosphor-logging/log.hpp>
+
+using namespace phosphor::logging;
namespace command
{
@@ -75,7 +77,7 @@
// Check if the RAKP3 Payload Length is as expected
if (inPayload.size() < sizeof(RAKP3request))
{
- std::cerr << "RAKP34: Invalid RAKP3 request\n";
+ log<level::INFO>("RAKP34: Invalid RAKP3 request");
response->rmcpStatusCode =
static_cast<uint8_t>(RAKP_ReturnCode::INVALID_INTEGRITY_VALUE);
return outPayload;
@@ -85,7 +87,7 @@
if (endian::from_ipmi(request->managedSystemSessionID) ==
session::SESSION_ZERO)
{
- std::cerr << "RAKP34: BMC invalid Session ID\n";
+ log<level::INFO>("RAKP34: BMC invalid Session ID");
response->rmcpStatusCode =
static_cast<uint8_t>(RAKP_ReturnCode::INVALID_SESSION_ID);
return outPayload;
@@ -100,7 +102,8 @@
}
catch (std::exception& e)
{
- std::cerr << e.what() << "\n";
+ log<level::ERR>("RAKP12 : session not found",
+ entry("EXCEPTION=%s", e.what()));
response->rmcpStatusCode =
static_cast<uint8_t>(RAKP_ReturnCode::INVALID_SESSION_ID);
return outPayload;
@@ -162,7 +165,7 @@
if (inPayload.size() != (sizeof(RAKP3request) + output.size()) ||
std::memcmp(output.data(), request + 1, output.size()))
{
- std::cerr << "Mismatch in HMAC sent by remote console\n";
+ log<level::INFO>("Mismatch in HMAC sent by remote console");
response->messageTag = request->messageTag;
response->rmcpStatusCode =
diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp
index 5c74d28..3312c92 100644
--- a/command/session_cmds.cpp
+++ b/command/session_cmds.cpp
@@ -5,7 +5,6 @@
#include <host-ipmid/ipmid-api.h>
-#include <iostream>
#include <user_channel/channel_layer.hpp>
#include <user_channel/user_layer.hpp>