Skip to content

Commit

Permalink
Reverting pldmtool traces
Browse files Browse the repository at this point in the history
- pldmtool is console based tool and while printing messages on
console using lg2 format then it's adding extra unwanted things
like line no, braces etc.

- lg2 is systemd journal specific logging mechanism so we don't
require lg2 in pldmtool directory so reverting changes only for
pldmtool directory.

Signed-off-by: Kamalkumar Patel <[email protected]>
  • Loading branch information
Patel-Kamalkumar committed Jan 18, 2024
1 parent 738cfd0 commit 5db8013
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 111 deletions.
17 changes: 6 additions & 11 deletions pldmtool/oem/ibm/pldm_oem_ibm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@

#include <endian.h>

#include <phosphor-logging/lg2.hpp>

#include <iostream>
#include <string>

PHOSPHOR_LOG2_USING;

namespace pldmtool
{

Expand Down Expand Up @@ -76,8 +71,8 @@ class GetAlertStatus : public CommandInterface

if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
{
error("Response Message Error: rc={RC} cc={CC}", "RC", rc, "CC",
static_cast<int>(completionCode));
std::cerr << "Response Message Error: "
<< "rc=" << rc << ",cc=" << (int)completionCode << "\n";
return;
}

Expand Down Expand Up @@ -126,15 +121,15 @@ class GetFileTable : public CommandInterface
0, request);
if (rc != PLDM_SUCCESS)
{
error("PLDM: Request Message Error, rc ={RC}", "RC", rc);
std::cerr << "PLDM: Request Message Error, rc =" << rc << std::endl;
return;
}

std::vector<uint8_t> responseMsg;
rc = pldmSendRecv(requestMsg, responseMsg);
if (rc != PLDM_SUCCESS)
{
error("PLDM: Communication Error, rc ={RC}", "RC", rc);
std::cerr << "PLDM: Communication Error, rc =" << rc << std::endl;
return;
}

Expand All @@ -153,8 +148,8 @@ class GetFileTable : public CommandInterface

if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc={RC} cc={CC}", "RC", rc, "CC",
static_cast<int>(cc));
std::cerr << "Response Message Error: "
<< ", rc=" << rc << ", cc=" << (int)cc << std::endl;
return;
}

Expand Down
18 changes: 8 additions & 10 deletions pldmtool/pldm_base_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <string>

PHOSPHOR_LOG2_USING;

namespace pldmtool
{

Expand Down Expand Up @@ -113,8 +111,8 @@ class GetPLDMTypes : public CommandInterface
types.data());
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);
return;
}

Expand Down Expand Up @@ -184,8 +182,8 @@ class GetPLDMVersion : public CommandInterface
&version);
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);
return;
}
char buffer[16] = {0};
Expand Down Expand Up @@ -234,8 +232,8 @@ class GetTID : public CommandInterface
auto rc = decode_get_tid_resp(responsePtr, payloadLength, &cc, &tid);
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error:rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error:rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);
return;
}
ordered_json data;
Expand Down Expand Up @@ -282,8 +280,8 @@ class GetPLDMCommands : public CommandInterface
cmdTypes.data());
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);
return;
}
printPldmCommands(cmdTypes, pldmType);
Expand Down
63 changes: 31 additions & 32 deletions pldmtool/pldm_bios_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <map>
#include <optional>

PHOSPHOR_LOG2_USING;

namespace pldmtool
{

Expand Down Expand Up @@ -75,8 +73,8 @@ class GetDateTime : public CommandInterface
&month, &year);
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);
return;
}

Expand Down Expand Up @@ -133,7 +131,7 @@ class SetDateTime : public CommandInterface
if (!uintToDate(tmData, &year, &month, &day, &hours, &minutes,
&seconds))
{
error("decode date Error: tmData={KEY0}", "KEY0", tmData);
lg2::error("decode date Error: tmData={KEY0}", "KEY0", tmData);

return {PLDM_ERROR_INVALID_DATA, requestMsg};
}
Expand All @@ -153,8 +151,8 @@ class SetDateTime : public CommandInterface

if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)completionCode);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)completionCode);

return;
}
Expand Down Expand Up @@ -212,15 +210,16 @@ class GetBIOSTableHandler : public CommandInterface
tableType, request);
if (rc != PLDM_SUCCESS)
{
error("Encode GetBIOSTable Error, tableType= {KEY0}, rc = {KEY1}",
"KEY0", pldmBIOSTableMap.at(tableType), "KEY1", rc);
lg2::error(
"Encode GetBIOSTable Error, tableType= {KEY0}, rc = {KEY1}",
"KEY0", pldmBIOSTableMap.at(tableType), "KEY1", rc);
return std::nullopt;
}
std::vector<uint8_t> responseMsg;
rc = pldmSendRecv(requestMsg, responseMsg);
if (rc != PLDM_SUCCESS)
{
error("PLDM: Communication Error, rc ={KEY0}", "KEY0", rc);
lg2::error("PLDM: Communication Error, rc ={KEY0}", "KEY0", rc);
return std::nullopt;
}

Expand All @@ -237,7 +236,7 @@ class GetBIOSTableHandler : public CommandInterface

if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error(
lg2::error(
"GetBIOSTable Response Error: tableType={KEY0}, rc ={KEY1}, cc={KEY2}",
"KEY0", pldmBIOSTableMap.at(tableType), "KEY1", rc, "KEY2",
(int)cc);
Expand Down Expand Up @@ -379,7 +378,7 @@ class GetBIOSTableHandler : public CommandInterface
}
else
{
info("Get AttributeType failed.");
lg2::info("Get AttributeType failed.");
}
}
switch (attrType)
Expand Down Expand Up @@ -454,7 +453,7 @@ class GetBIOSTableHandler : public CommandInterface
case PLDM_BIOS_PASSWORD:
case PLDM_BIOS_PASSWORD_READ_ONLY:
{
info("Password attribute: Not Supported");
lg2::info("Password attribute: Not Supported");
break;
}
}
Expand Down Expand Up @@ -519,7 +518,7 @@ class GetBIOSTable : public GetBIOSTableHandler
{
if (!stringTable)
{
error("GetBIOSStringTable Error");
lg2::error("GetBIOSStringTable Error");
return;
}
ordered_json stringdata;
Expand All @@ -539,7 +538,7 @@ class GetBIOSTable : public GetBIOSTableHandler
{
if (!stringTable)
{
error("GetBIOSAttributeTable Error");
lg2::error("GetBIOSAttributeTable Error");
return;
}
ordered_json output;
Expand All @@ -565,7 +564,7 @@ class GetBIOSTable : public GetBIOSTableHandler
}
else
{
error("Get AttributeType failed.");
lg2::error("Get AttributeType failed.");
}

switch (attrType)
Expand Down Expand Up @@ -658,7 +657,7 @@ class GetBIOSTable : public GetBIOSTableHandler
}
case PLDM_BIOS_PASSWORD:
case PLDM_BIOS_PASSWORD_READ_ONLY:
alert("Password attribute: Not Supported");
lg2::alert("Password attribute: Not Supported");
}
output.emplace_back(std::move(attrdata));
}
Expand All @@ -670,7 +669,7 @@ class GetBIOSTable : public GetBIOSTableHandler
{
if (!attrValTable)
{
error("GetBIOSAttributeValueTable Error");
lg2::error("GetBIOSAttributeValueTable Error");
return;
}
ordered_json output;
Expand Down Expand Up @@ -715,14 +714,14 @@ class GetBIOSAttributeCurrentValueByHandle : public GetBIOSTableHandler

if (!stringTable || !attrTable)
{
info("StringTable/AttrTable Unavaliable");
lg2::info("StringTable/AttrTable Unavaliable");
return;
}

auto handle = findAttrHandleByName(attrName, *attrTable, *stringTable);
if (!handle)
{
error("Could not find the attribute {KEY0}", "KEY0", attrName);
lg2::error("Can not find the attribute {KEY0}", "KEY0", attrName);
return;
}

Expand All @@ -735,15 +734,15 @@ class GetBIOSAttributeCurrentValueByHandle : public GetBIOSTableHandler
instanceId, 0, PLDM_GET_FIRSTPART, *handle, request);
if (rc != PLDM_SUCCESS)
{
error("PLDM: Request Message Error, rc ={KEY0}", "KEY0", rc);
lg2::error("PLDM: Request Message Error, rc ={KEY0}", "KEY0", rc);
return;
}

std::vector<uint8_t> responseMsg;
rc = pldmSendRecv(requestMsg, responseMsg);
if (rc != PLDM_SUCCESS)
{
error("PLDM: Communication Error, rc ={KEY0}", "KEY0", rc);
lg2::error("PLDM: Communication Error, rc ={KEY0}", "KEY0", rc);
return;
}

Expand All @@ -759,8 +758,8 @@ class GetBIOSAttributeCurrentValueByHandle : public GetBIOSTableHandler
&attributeData);
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);

return;
}
Expand Down Expand Up @@ -810,15 +809,15 @@ class SetBIOSAttributeCurrentValue : public GetBIOSTableHandler

if (!stringTable || !attrTable)
{
info("StringTable/AttrTable Unavaliable");
lg2::info("StringTable/AttrTable Unavaliable");
return;
}

auto attrEntry = findAttrEntryByName(attrName, *attrTable,
*stringTable);
if (attrEntry == nullptr)
{
info("Could not find attribute :{KEY0}", "KEY0", attrName);
lg2::info("Could not find attribute :{KEY0}", "KEY0", attrName);
return;
}

Expand Down Expand Up @@ -849,7 +848,7 @@ class SetBIOSAttributeCurrentValue : public GetBIOSTableHandler
attrValue.c_str());
if (stringEntry == nullptr)
{
info("Set Attribute Error: It's not a possible value");
lg2::info("Set Attribute Error: It's not a possible value");

return;
}
Expand All @@ -864,7 +863,7 @@ class SetBIOSAttributeCurrentValue : public GetBIOSTableHandler
}
if (i == pvNum)
{
info("Set Attribute Error: It's not a possible value");
lg2::info("Set Attribute Error: It's not a possible value");
return;
}

Expand Down Expand Up @@ -935,14 +934,14 @@ class SetBIOSAttributeCurrentValue : public GetBIOSTableHandler

if (rc != PLDM_SUCCESS)
{
error("PLDM: Request Message Error, rc ={KEY0}", "KEY0", rc);
lg2::error("PLDM: Request Message Error, rc ={KEY0}", "KEY0", rc);
return;
}
std::vector<uint8_t> responseMsg;
rc = pldmSendRecv(requestMsg, responseMsg);
if (rc != PLDM_SUCCESS)
{
error("PLDM: Communication Error, rc ={KEY0}", "KEY0", rc);
lg2::error("PLDM: Communication Error, rc ={KEY0}", "KEY0", rc);
return;
}
uint8_t cc = 0;
Expand All @@ -955,8 +954,8 @@ class SetBIOSAttributeCurrentValue : public GetBIOSTableHandler
responsePtr, payloadLength, &cc, &nextTransferHandle);
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0", rc,
"KEY1", (int)cc);
lg2::error("Response Message Error: rc = {KEY0}, cc={KEY1}", "KEY0",
rc, "KEY1", (int)cc);
return;
}

Expand Down
Loading

0 comments on commit 5db8013

Please sign in to comment.