Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bmc-acf: use lg2 and improve logging #45

Open
wants to merge 1 commit into
base: 1110
Choose a base branch
from

Conversation

joseph-reynolds
Copy link

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.

@joseph-reynolds joseph-reynolds force-pushed the 1110-bmc-acf-fix-error-logs branch from 4bb4e4f to c427165 Compare December 5, 2024 21:42
@@ -88,14 +88,13 @@ acf_info ACFCertMgr::installACF(std::vector<uint8_t> accessControlFile)
}
// Verify and install ACF and get expiration date.
Tacf tacf{[](std::string msg) {
log<phosphor::logging::level::INFO>(msg.c_str());
lg2::info(msg.c_str());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg2 can take strings, so you don't need the c_str().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've removed the unnecessary conversion. The code looked like this (lambda function):

[](std::string msg) { lg2::info(msg); }

In doing so, a funny thing happened. The C++ compiler complained that I was (1) declaring msg again, shadowing the parameter, (2) the parens around (msg) were unnecessary, and (3) I was using deleted function 'lg2::info<>::info()'.
So I added a literal format string.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the lg2 author didn't want people passing in the whole message as an arg.

}};
int rc = tacf.verify(accessControlFile.data(), accessControlFile.size(),
sDate);
if (rc)
{
log<level::INFO>("ACF is not valid");
log<level::ERR>("Error: ", entry("rc=%0x", rc));
lg2::error("Error: ACF is not valid, rc=0x{RC}", "RC", lg2::hex, rc);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg2 will add the 0x itself so you don't need to.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've removed it now.

@joseph-reynolds joseph-reynolds force-pushed the 1110-bmc-acf-fix-error-logs branch 2 times, most recently from 94b733e to 0929fe9 Compare December 5, 2024 22:21
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 <joseph.reynolds1@ibm.com>
@joseph-reynolds joseph-reynolds force-pushed the 1110-bmc-acf-fix-error-logs branch from 0929fe9 to 1ab6b02 Compare December 5, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants