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

* Re: Use the right values for CODE_LINE and CODE_FUNC in journal traces
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Williams @ 2021-05-13  1:51 UTC (permalink / raw)
  To: George Liu; +Cc: OpenBMC Maillist

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

On Tue, May 11, 2021 at 02:03:19PM +0800, George Liu wrote:
> 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.

There was similiar discussion in the past of using source_location to
get the real file/line as you suggested.  I don't think anyone put tons
of thought into how to get it into the function though.

source_location isn't supported by GCC until 11 per [1] and we don't
have that in Yocto yet.  I know I was at least holding off until we get
that to do much experimentation.

1. https://en.cppreference.com/w/cpp/compiler_support

-- 
Patrick Williams

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Use the right values for CODE_LINE and CODE_FUNC in journal traces
  2021-05-13  1:51 ` Patrick Williams
@ 2021-05-13  2:09   ` George Liu
  0 siblings, 0 replies; 3+ messages in thread
From: George Liu @ 2021-05-13  2:09 UTC (permalink / raw)
  To: Patrick Williams; +Cc: OpenBMC Maillist

On Thu, May 13, 2021 at 9:51 AM Patrick Williams <patrick@stwcx.xyz> wrote:
>
> On Tue, May 11, 2021 at 02:03:19PM +0800, George Liu wrote:
> > 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.
>
> There was similiar discussion in the past of using source_location to
> get the real file/line as you suggested.  I don't think anyone put tons
> of thought into how to get it into the function though.
>
> source_location isn't supported by GCC until 11 per [1] and we don't
> have that in Yocto yet.  I know I was at least holding off until we get
> that to do much experimentation.
>
> 1. https://en.cppreference.com/w/cpp/compiler_support
>
> --
> Patrick Williams

Thanks Patrick.
We will keep following up.

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.