improve enum logging
Ensure we're using an enumeration string everywhere we log one to
improve readability of the log statements.
This depends on I6850b0bb142f0ef5219a5fc07c2cb4e2c90d5779 from
phosphor-logging for `to_string` conversion support.
Tested:
Running directly on development system shows:
```
<7> TYPE=CPU, NAME=CPU SUBTYPE=CPU PATH=, FREQ=1, WSIZE=120
<7> THRESHOLD TYPE=xyz.openbmc_project.Common.Threshold.Type.Warning THRESHOLD BOUND=xyz.openbmc_project.Common.Threshold.Bound.Upper VALUE=80.000000 LOG=False TARGET=
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I5ea7a050e94833af272e79e6add716d1d3e66571
diff --git a/health_metric_collection.cpp b/health_metric_collection.cpp
index ae7d593..ea587ac 100644
--- a/health_metric_collection.cpp
+++ b/health_metric_collection.cpp
@@ -99,9 +99,8 @@
preTotalTime[config.subType] = totalTime;
activePercValue = (100.0 * activeTimeDiff) / totalTimeDiff;
- debug("CPU Metric {SUBTYPE}: {VALUE}", "SUBTYPE",
- std::to_underlying(config.subType), "VALUE",
- (double)activePercValue);
+ debug("CPU Metric {SUBTYPE}: {VALUE}", "SUBTYPE", config.subType,
+ "VALUE", (double)activePercValue);
/* For CPU, both user and monitor uses percentage values */
metrics[config.subType]->update(MValue(activePercValue, 100));
}
@@ -159,8 +158,7 @@
auto value = memoryValues.at(config.subType) * 1024;
auto total = memoryValues.at(MetricIntf::SubType::memoryTotal) * 1024;
debug("Memory Metric {SUBTYPE}: {VALUE}, {TOTAL}", "SUBTYPE",
- std::to_underlying(config.subType), "VALUE", value, "TOTAL",
- total);
+ config.subType, "VALUE", value, "TOTAL", total);
metrics[config.subType]->update(MValue(value, total));
}
return true;
@@ -181,8 +179,7 @@
double value = buffer.f_bfree * buffer.f_frsize;
double total = buffer.f_blocks * buffer.f_frsize;
debug("Storage Metric {SUBTYPE}: {VALUE}, {TOTAL}", "SUBTYPE",
- std::to_underlying(config.subType), "VALUE", value, "TOTAL",
- total);
+ config.subType, "VALUE", value, "TOTAL", total);
metrics[config.subType]->update(MValue(value, total));
}
return true;
@@ -218,8 +215,7 @@
}
default:
{
- error("Unknown health metric type {TYPE}", "TYPE",
- std::to_underlying(type));
+ error("Unknown health metric type {TYPE}", "TYPE", type);
break;
}
}