History log of /openbmc/phosphor-logging/lib/lg2_logger.cpp (Results 1 – 13 of 13)
Revision Date Author Comments
# 3857579e 03-Dec-2024 Patrick Williams <patrick@stwcx.xyz>

lg2: use DEBUG_INVOCATION to reduce debug journal

The systemd-v257 release introduced a new convention that can be used
by daemons to reduce the amount of calls to journald for debug-level
messages:

lg2: use DEBUG_INVOCATION to reduce debug journal

The systemd-v257 release introduced a new convention that can be used
by daemons to reduce the amount of calls to journald for debug-level
messages: DEBUG_INVOCATION[1]. Daemons will typically start with
DEBUG_INVOCATION not set, but in the event of a crash, the daemon will
be restarted with it set. Daemons are expected to emit higher debug
messages when ran in that mode.

Adjusting the logger code to avoid sending debug messages to journald
unless DEBUG_INVOCATION is set. This reduces the overhead of logging
by skipping the journald calls entirely.

[1]: https://github.com/systemd/systemd/commit/7d8bbfbe0852ec89590d1dc5e28afc95d6d44fa1

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I5896c4714b92786c8f859f2e5ab389753e4b5c26

show more ...


# 075c7923 16-Aug-2024 Patrick Williams <patrick@stwcx.xyz>

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda forma

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: I21d2ca8065f24fd73509229c517f5caf48934b60
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# 230f9f94 20-Jul-2023 Josh Lehan <krellan@google.com>

lg2: Add mutex to avoid stderr line corruption

Use of a mutex, along with flushing after every line, prevents threads
in multithreaded programs from corrupting each other's stderr logging
lines. As

lg2: Add mutex to avoid stderr line corruption

Use of a mutex, along with flushing after every line, prevents threads
in multithreaded programs from corrupting each other's stderr logging
lines. As for the D-Bus journal messages, they are already atomic, not
needing this fix.

Tested: The corruption appears fixed
https://gist.github.com/Krellan/d5d9942cb5ab405c9689e4eb4bb75cf0

Change-Id: I1db88139406eb617aa713740d5ccb6c9420ca773
Signed-off-by: Josh Lehan <krellan@google.com>

show more ...


# 7f5e4410 23-Jun-2023 Patrick Williams <patrick@stwcx.xyz>

lg2: simplify source_location for clang-16

As of clang-16, `source_location` is fully supported, so we do not need
to use the `experimental::source_location` workarounds anymore.
Eliminate them and

lg2: simplify source_location for clang-16

As of clang-16, `source_location` is fully supported, so we do not need
to use the `experimental::source_location` workarounds anymore.
Eliminate them and use `std::source_location` directly rather than the
`lg2::source_location` alias.

Tested: Compiled the repository with CXX=clang++.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iba987ed9580d228781acac630681fda172a6cef7

show more ...


# 2544b419 04-Oct-2022 Patrick Williams <patrick@stwcx.xyz>

clang-format: update with latest

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I329396457b83bb2eb8740629b4ac1fbe9106bced


# ea06f8ec 25-Mar-2022 Zane Shelley <zshelle@us.ibm.com>

Enable lg2 log output to stderr in OpenBMC CI test

Similar to printing logs to stderr in a TTY, output to stderr can be
enabled during OpenBMC CI test by setting the `LG2_FORCE_STDERR`
environment v

Enable lg2 log output to stderr in OpenBMC CI test

Similar to printing logs to stderr in a TTY, output to stderr can be
enabled during OpenBMC CI test by setting the `LG2_FORCE_STDERR`
environment variable to any value.

Using meson, this can be done with something like:

test('test_name', executable(...), env: ['LG2_FORCE_STDERR=yes'])

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I0323fbb75fe211148ec4dc7e263fe18aabb8ffc6

show more ...


# 7460ce02 03-Mar-2022 Patrick Williams <patrick@stwcx.xyz>

lg2: add experimental::source_location symbols on GCC

When we compile with a compiler that supports the C++20 source_location,
we use that support and do not support the older experimental version.

lg2: add experimental::source_location symbols on GCC

When we compile with a compiler that supports the C++20 source_location,
we use that support and do not support the older experimental version.
Recent versions of GCC support it but Clang does not. This exposes an
issue when attempting to link a GCC-compiled lg2 with a Clang-compiled
application (missing symbol for experimental version).

Add a no-op symbol for experimental::source_location when the compiler
supports std::source_location. This allows the Clang-compiled
applications to successfully compile and link, but they will lose out on
the lg2 functionality. The primary use-case of this is to compile with
Clang in CI in order to get signal on the stricter warnings that Clang
often has, so functionality is not necessary.

Tested:

Built with GCC and confirmed additional symbol for
experimental::source_location support.

```
$ nm lib/libphosphor_logging.so.1.0.0 --defined-only -C | grep lg2::details::do_log
0000000000004520 T lg2::details::do_log(lg2::level, std::experimental::fundamentals_v2::source_location const&, char const*, ...)
0000000000004aa0 T lg2::details::do_log(lg2::level, std::source_location const&, char const*, ...)
0000000000003682 t lg2::details::do_log(lg2::level, std::source_location const&, char const*, ...) [clone .cold]
```

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I4bc0b9f6619ce6088dfa44a3c18eb28d9080fb47

show more ...


# a9e4f596 19-Nov-2021 Jonathan Doman <jonathan.doman@intel.com>

lg2: Reset format string for multiple uses

The stderr output format string pointer was incremented during
processing, and never reset, resulting in empty output to cerr on all
log messages beyond th

lg2: Reset format string for multiple uses

The stderr output format string pointer was incremented during
processing, and never reset, resulting in empty output to cerr on all
log messages beyond the first. This resets the pointer on each call.

Tested: Issued multiple lg2::info calls and observed them all on stderr.

Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Change-Id: I1a2b3eaa23604b5260ee61c3167f6956018f034d

show more ...


# 5dffc2d9 14-Nov-2021 Patrick Williams <patrick@stwcx.xyz>

lg2: reduce stdout and allow customization

It was reported by users that the information logged to the TTY was too
much in many cases, which limited the usability of lg2. Allow users to
customize t

lg2: reduce stdout and allow customization

It was reported by users that the information logged to the TTY was too
much in many cases, which limited the usability of lg2. Allow users to
customize the output by setting the "LG2_FORMAT" environment variable
and limit the default output to just "<level> message".

Tested:

Added a simple log to the beginning of an existing daemon and tested
format strings:

```
$ ./health-monitor
<6> Here I am!
$ LG2_FORMAT="{%l} %m %% [%f:%L:%F]|%" ./health-monitor
{6} Here I am! % [int main():511:../healthMonitor.cpp]|%
```

Resolves openbmc/phosphor-logging#26.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie50c90f073539812c0693d05fc04ce7ad2b3fbcd

show more ...


# a91a62b0 28-Aug-2021 Patrick Williams <patrick@stwcx.xyz>

lg2: workaround clang-tidy's lack of source_location

clang/clang-tidy do not currently support C++20 source_location,
which causes repositories attempting to use lg2 but with clang-tidy
enabled to f

lg2: workaround clang-tidy's lack of source_location

clang/clang-tidy do not currently support C++20 source_location,
which causes repositories attempting to use lg2 but with clang-tidy
enabled to fail with lots of missing-type errors. Workaround this
by detecting the situation and falling back to use
std::experimental::source_location.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Idb5a555243568c394505890035423d39e9b22407

show more ...


# b1811b31 26-Aug-2021 Patrick Williams <patrick@stwcx.xyz>

lg2: minor size optimization in do_log

Push the calculation of the number of logging arguments into the
variadic 'do_log' function rather than calculate it at the lg2
call site. This reduces each c

lg2: minor size optimization in do_log

Push the calculation of the number of logging arguments into the
variadic 'do_log' function rather than calculate it at the lg2
call site. This reduces each call site by a few instructions.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ic8fcbdf65fb34d251d8110c5bbd05c2e20c66c18

show more ...


# b5988ff8 26-Aug-2021 Patrick Williams <patrick@stwcx.xyz>

lg2: reduce string_view for size optimize

There were a few places where string_view's were used for simplicity,
but as a result the compiler ends up instantiating temporary
string_view objects, whic

lg2: reduce string_view for size optimize

There were a few places where string_view's were used for simplicity,
but as a result the compiler ends up instantiating temporary
string_view objects, which makes the generated code larger. Switch
to 'const char*' instead and avoid needless string_view constructions.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia29470e8db0f1489bf7b5f6a18b1af0877d0ce72

show more ...


# b2a3aa2f 27-Jul-2021 Patrick Williams <patrick@stwcx.xyz>

lg2: initial implementation of C++20 structured logging

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If37857cc3748df1ea6f767ce535b02c63cde8370