Skip to content

Commit ca6de4e

Browse files
committed
pldm: Verbose pldmd sensor and effecter log messages
Log sensor read or parse errors only if pldmd is running in verbose mode. Signed-off-by: Shirish Pargaonkar <Shirish.Pargaonkar@amd.com>
1 parent c2f346a commit ca6de4e

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

platform-mc/manager.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Manager : public pldm::MctpDiscoveryHandlerIntf
4040
terminusManager(event, handler, instanceIdDb, termini, this,
4141
pldm::BmcMctpEid),
4242
platformManager(terminusManager, termini, this),
43-
sensorManager(event, terminusManager, termini, this),
43+
sensorManager(event, terminusManager, termini, this, verbose),
4444
eventManager(terminusManager, termini, verbose)
4545
{this->verbose = verbose;}
4646

@@ -285,6 +285,7 @@ class Manager : public pldm::MctpDiscoveryHandlerIntf
285285
/** @brief map of PLDM event type to EventHandlers */
286286
PollHandlers pollHandlers;
287287

288+
/** @brief Enable verbose logging for debug purposes */
288289
bool verbose{false};
289290
};
290291
} // namespace platform_mc

platform-mc/sensor_manager.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ namespace platform_mc
1414

1515
SensorManager::SensorManager(sdeventplus::Event& event,
1616
TerminusManager& terminusManager,
17-
TerminiMapper& termini, Manager* manager) :
17+
TerminiMapper& termini, Manager* manager,
18+
const bool verbose) :
1819
event(event), terminusManager(terminusManager), termini(termini),
1920
pollingTime(SENSOR_POLLING_TIME), manager(manager)
20-
{}
21+
{this->verbose = verbose;}
2122

2223
void SensorManager::startPolling(pldm_tid_t tid)
2324
{
@@ -270,9 +271,11 @@ exec::task<int> SensorManager::doSensorPollingTask(pldm_tid_t tid)
270271
}
271272
else
272273
{
273-
lg2::error(
274-
"Failed to get sensor value for terminus {TID}, error: {RC}",
275-
"TID", tid, "RC", rc);
274+
if (verbose) {
275+
lg2::error(
276+
"Failed to get sensor value for terminus {TID}, error: {RC}",
277+
"TID", tid, "RC", rc);
278+
}
276279
}
277280
}
278281

@@ -351,9 +354,11 @@ exec::task<int> SensorManager::getSensorReading(
351354
reinterpret_cast<uint8_t*>(&presentReading));
352355
if (rc)
353356
{
354-
lg2::error(
355-
"Failed to decode response GetSensorReading for terminus ID {TID}, sensor Id {ID}, error {RC}.",
356-
"TID", tid, "ID", sensorId, "RC", rc);
357+
if (verbose) {
358+
lg2::error(
359+
"Failed to decode response GetSensorReading for terminus ID {TID}, sensor Id {ID}, error {RC}.",
360+
"TID", tid, "ID", sensorId, "RC", rc);
361+
}
357362
sensor->handleErrGetSensorReading();
358363
co_return rc;
359364
}

platform-mc/sensor_manager.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class SensorManager
4040

4141
explicit SensorManager(sdeventplus::Event& event,
4242
TerminusManager& terminusManager,
43-
TerminiMapper& termini, Manager* manager);
43+
TerminiMapper& termini, Manager* manager,
44+
const bool verbose);
4445

4546
/** @brief starting sensor polling task
4647
*/
@@ -124,6 +125,9 @@ class SensorManager
124125

125126
/** @brief pointer to Manager */
126127
Manager* manager;
128+
129+
/** @brief Enable verbose logging for debug purposes */
130+
bool verbose{false};
127131
};
128132
} // namespace platform_mc
129133
} // namespace pldm

0 commit comments

Comments
 (0)