-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: 1110
Are you sure you want to change the base?
bmc-acf: use lg2 and improve logging #45
Conversation
4bb4e4f
to
c427165
Compare
bmc-acf/acf_manager.cpp
Outdated
@@ -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()); |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bmc-acf/acf_manager.cpp
Outdated
}}; | ||
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
94b733e
to
0929fe9
Compare
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>
0929fe9
to
1ab6b02
Compare
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.