Skip to content

Commit 0929fe9

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. Made required formatting changes in unrelated modules. 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 0929fe9

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

bmc-acf/acf_manager.cpp

Lines changed: 6 additions & 12 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

@@ -87,15 +87,12 @@ acf_info ACFCertMgr::installACF(std::vector<uint8_t> accessControlFile)
8787
return std::make_tuple(accessControlFile, acfInstalled(), sDate);
8888
}
8989
// Verify and install ACF and get expiration date.
90-
Tacf tacf{[](std::string msg) {
91-
log<phosphor::logging::level::INFO>(msg.c_str());
92-
}};
90+
Tacf tacf{[](std::string msg) { lg2::info("Note: {MSG}", "MSG", msg); }};
9391
int rc = tacf.install(accessControlFile.data(), accessControlFile.size(),
9492
sDate);
9593
if (rc)
9694
{
97-
log<level::INFO>("ACF install failed");
98-
log<level::ERR>("Error: ", entry("rc=%0x", rc));
95+
lg2::error("Error: ACF install failed, rc={RC}", "RC", lg2::hex, rc);
9996
elog<InvalidCertificate>(Reason("ACF validation failed"));
10097
}
10198

@@ -109,20 +106,17 @@ std::tuple<std::vector<uint8_t>, bool, std::string> ACFCertMgr::getACFInfo(void)
109106

110107
if (!readBinaryFile(ACF_FILE_PATH, accessControlFile))
111108
{
112-
log<level::ERR>("ACF not installed or not readable");
109+
lg2::error("ACF not installed or not readable");
113110
}
114111
else
115112
{
116113
// Verify ACF and get expiration date.
117-
Tacf tacf{[](std::string msg) {
118-
log<phosphor::logging::level::INFO>(msg.c_str());
119-
}};
114+
Tacf tacf{[](std::string msg) { lg2::info("Note: {MSG}", "MSG", msg); }};
120115
int rc = tacf.verify(accessControlFile.data(), accessControlFile.size(),
121116
sDate);
122117
if (rc)
123118
{
124-
log<level::INFO>("ACF is not valid");
125-
log<level::ERR>("Error: ", entry("rc=%0x", rc));
119+
lg2::error("Error: ACF is not valid, rc={RC}", "RC", lg2::hex, rc);
126120
accessControlFile.clear();
127121
sDate.clear();
128122
}

bmc-acf/acf_manager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class ACFCertMgr : public CreateIface
3838
*/
3939
ACFCertMgr(sdbusplus::bus::bus& bus, sdeventplus::Event& event,
4040
const char* path) :
41-
CreateIface(bus, path),
42-
bus(bus), event(event), objectPath(path), lastEntryId(0){};
41+
CreateIface(bus, path), bus(bus), event(event), objectPath(path),
42+
lastEntryId(0) {};
4343

4444
/** @brief Implementation for InstallACF
4545
* Replace the existing ACF with another ACF

bmc-vmi-ca/ca_certs_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CACertMgr : public internal::ManagerInterface
3939
*/
4040
CACertMgr(sdbusplus::bus_t& bus, const char* path) :
4141
internal::ManagerInterface(bus, path), bus(bus), objectPath(path),
42-
lastEntryId(0){};
42+
lastEntryId(0) {};
4343

4444
/** @brief This method provides signing authority functionality.
4545
It signs the certificate and creates the CSR request entry Dbus

certs_manager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ std::vector<std::string> splitCertificates(const std::string& sourceFilePath)
143143
Manager::Manager(sdbusplus::bus_t& bus, sdeventplus::Event& event,
144144
const char* path, CertificateType type,
145145
const std::string& unit, const std::string& installPath) :
146-
internal::ManagerInterface(bus, path),
147-
bus(bus), event(event), objectPath(path), certType(type),
148-
unitToRestart(std::move(unit)), certInstallPath(std::move(installPath)),
146+
internal::ManagerInterface(bus, path), bus(bus), event(event),
147+
objectPath(path), certType(type), unitToRestart(std::move(unit)),
148+
certInstallPath(std::move(installPath)),
149149
certParentInstallPath(fs::path(certInstallPath).parent_path())
150150
{
151151
try

test/certs_manager_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ class MainApp
214214
{
215215
public:
216216
MainApp(phosphor::certs::Manager* manager,
217-
phosphor::certs::CSR* csr = nullptr) :
218-
manager(manager),
219-
csr_(csr)
217+
phosphor::certs::CSR* csr = nullptr) : manager(manager), csr_(csr)
220218
{}
221219
void install(std::string& path)
222220
{

0 commit comments

Comments
 (0)