Skip to content

Commit 4bb4e4f

Browse files
bmc-acf: use lg2 and improve logging
This changes the bmc-acf code to use lg2 (move away from log) and fix problems with unacceptable (lowercase) journald keywords, and reduce the number of log entries writen. Tested: Attempted to reproduce each log entry, and validate it is written correctly to the journal. Signed-off-by: Joseph Reynolds <[email protected]>
1 parent b788ebe commit 4bb4e4f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

bmc-acf/acf_manager.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <acf_manager.hpp>
22
#include <phosphor-logging/elog-errors.hpp>
33
#include <phosphor-logging/elog.hpp>
4-
#include <phosphor-logging/log.hpp>
4+
#include <phosphor-logging/lg2.hpp>
55
#include <tacf.hpp>
66
#include <xyz/openbmc_project/Certs/error.hpp>
77

@@ -88,14 +88,13 @@ acf_info ACFCertMgr::installACF(std::vector<uint8_t> accessControlFile)
8888
}
8989
// Verify and install ACF and get expiration date.
9090
Tacf tacf{[](std::string msg) {
91-
log<phosphor::logging::level::INFO>(msg.c_str());
91+
lg2::info(msg.c_str());
9292
}};
9393
int rc = tacf.install(accessControlFile.data(), accessControlFile.size(),
9494
sDate);
9595
if (rc)
9696
{
97-
log<level::INFO>("ACF install failed");
98-
log<level::ERR>("Error: ", entry("rc=%0x", rc));
97+
lg2::error("Error: ACF install failed, rc=0x{RC}", "RC", hex, rc);
9998
elog<InvalidCertificate>(Reason("ACF validation failed"));
10099
}
101100

@@ -109,20 +108,19 @@ std::tuple<std::vector<uint8_t>, bool, std::string> ACFCertMgr::getACFInfo(void)
109108

110109
if (!readBinaryFile(ACF_FILE_PATH, accessControlFile))
111110
{
112-
log<level::ERR>("ACF not installed or not readable");
111+
lg2::error("ACF not installed or not readable");
113112
}
114113
else
115114
{
116115
// Verify ACF and get expiration date.
117116
Tacf tacf{[](std::string msg) {
118-
log<phosphor::logging::level::INFO>(msg.c_str());
117+
lg2::info(msg.c_str());
119118
}};
120119
int rc = tacf.verify(accessControlFile.data(), accessControlFile.size(),
121120
sDate);
122121
if (rc)
123122
{
124-
log<level::INFO>("ACF is not valid");
125-
log<level::ERR>("Error: ", entry("rc=%0x", rc));
123+
lg2::error("Error: ACF is not valid, rc=0x{RC}", "RC", hex, rc);
126124
accessControlFile.clear();
127125
sDate.clear();
128126
}

0 commit comments

Comments
 (0)