Use the right values for CODE_LINE and CODE_FUNC in journal traces

George Liu liuxiwei1013 at
Tue May 11 16:03:19 AEST 2021

Hey everyone:

I have a question:
When we track the CODE_LINE and CODE_FUNC values in the journal, the
CODE_LINE and CODE_FUNC attribute values are displayed incorrectly.
issue link:

Today, OpenBMC has supported C++20, and has included
`experimental/source_location` in C++20, which can flexibly obtain the
CODE_LINE and CODE_FUNC attribute values.
The following is an example:

void log(const std::string_view& message, const
std::experimental::source_location& location =
    std::cout << "info:" << location.file_name() << ":" <<
location.line() << " " << message << '\n';

int main()
    log("Hello world!");

So my initial idea is to define `const
std::experimental::source_location& location =
std::experimental::source_location::current()` into the log method.
But for the log method, has defined a variable parameter, so it can
not receive a default parameter again.

Does everyone have a better way to process it? Please let me know and
we can discuss it here.

Thanks a lot.

George Liu

More information about the openbmc mailing list