All of lore.kernel.org
 help / color / mirror / Atom feed
* Use the right values for CODE_LINE and CODE_FUNC in journal traces
@ 2021-05-11  6:03 George Liu
  2021-05-13  1:51 ` Patrick Williams
  0 siblings, 1 reply; 3+ messages in thread
From: George Liu @ 2021-05-11  6:03 UTC (permalink / raw)
  To: OpenBMC Maillist

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: https://github.com/openbmc/openbmc/issues/2297

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::experimental::source_location::current())
{
    std::cout << "info:" << location.file_name() << ":" <<
location.line() << " " << message << '\n';
}

int main()
{
    log("Hello world!");
}
```
link: https://en.cppreference.com/w/cpp/utility/source_location

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.
link: https://github.com/openbmc/phosphor-logging/blob/master/phosphor-logging/log.hpp#L157

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

Thanks a lot.

George Liu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-13  2:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-11  6:03 Use the right values for CODE_LINE and CODE_FUNC in journal traces George Liu
2021-05-13  1:51 ` Patrick Williams
2021-05-13  2:09   ` George Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.