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 ...
|
31d78f77 | 07-Feb-2022 |
Stanley Chu <yschu@nuvoton.com> |
Fix wrong type of TRANSACTION_ID in journal metadata
In the log API, it prints message to systemd journal and also stores TRANSACTION_ID metadata with its value as %lld. However, the transaction id
Fix wrong type of TRANSACTION_ID in journal metadata
In the log API, it prints message to systemd journal and also stores TRANSACTION_ID metadata with its value as %lld. However, the transaction id is acquired from sdbusplus::server:: transaction::get_id(), which is a uint64_t. The type of TRANSACTION_ID metadata should be changed to %llu, otherwise phosphor::logging::internal::Manager::_commit() may not find the matched journal entry.
Signed-off-by: Stanley Chu <yschu@nuvoton.com> Change-Id: I2a70ae836ae33006a043569d2e3a692fcece7303
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 ...
|
87001e46 | 10-Sep-2021 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: apply clang-12 changes
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Id432a670d81a53425940fe36b2299f8781ecc3be |
36a34693 | 28-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: conversion: reduce std::forward clutter
It was observed in another repository that if the same std::string was passed twice into lg2 function that clang-tidy would complain about a potential us
lg2: conversion: reduce std::forward clutter
It was observed in another repository that if the same std::string was passed twice into lg2 function that clang-tidy would complain about a potential use-after-realloc due to the 'string.data()' call for the first instance followed by a 'std::forward' on the second instance. I don't think there was actually any issue with that, but we don't really leverage r-value references in this code because there is never an opportunity to 'std::move' any contents. Remove the clutter of 'std::forward' everywhere and simply rely on l-value references, which is all the code needs anyhow. This also placated clang-tidy's memory use checker.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I89582e2f868732e9a7a08a7a24f858b9130d56bc
show more ...
|
e917611a | 28-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: fix clang static_assert fire
There are variants of the conversion functions that are in place simply to provide better diagnostics to users when they pass the wrong content into a `lg2::log` fu
lg2: fix clang static_assert fire
There are variants of the conversion functions that are in place simply to provide better diagnostics to users when they pass the wrong content into a `lg2::log` function. Most of these use `static_assert`s which can only fire when the compiler is able to deduce the appropriate types, and thus the function is incorrectly being used.
clang happens to be smarter than that. Even when it cannot deduce the types necessary to fully instantiate the function, the asserts can fire if all of the types necessary for the `static_assert` were deduced. Thus a `static_assert` like this can trigger:
static_assert(!std::is_same<foo, foo>, ...)
Workaround this by ensuring that at least one un-deduced type is included in all of these diagnostic-function-only `static_assert`.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I025e08661c6250c886803dfc308ad6acbd7e57cb
show more ...
|
d7888592 | 28-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: fix clang issue on nullptr_t
clang-tidy is more pedantic that nullptr_t is actually in std and fails unless it is specified as such.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-
lg2: fix clang issue on nullptr_t
clang-tidy is more pedantic that nullptr_t is actually in std and fails unless it is specified as such.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I74aa5a5af17fd5d4610fed4707564576c6ac22f1
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 ...
|
c4845d9a | 27-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: conversion: support std::filesystem::path natively
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ied02e149fd471e25ef1a07f05e437204d2d770cc |
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 ...
|
816eedfc | 26-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: missing include for ranges::find
The lg2/header.hpp used ranges::find but didn't include the defining header file (algorithm). This was probably missed because in many cases algorithm is pulle
lg2: missing include for ranges::find
The lg2/header.hpp used ranges::find but didn't include the defining header file (algorithm). This was probably missed because in many cases algorithm is pulled in as a dependency from other STL headers, but if you make an empty file with nothing except 'include <phosphor-logging/lg2.hpp>' the function definition is missing.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I64cd7edcacaccb02b15904486010c3bce5c28dba
show more ...
|
465ab60c | 05-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: compile time checking for reserved header names
Add compile time checking for reserved header names like 'MESSAGE' as these would override the meaning at a journald level.
This bug was identif
lg2: compile time checking for reserved header names
Add compile time checking for reserved header names like 'MESSAGE' as these would override the meaning at a journald level.
This bug was identified in the review of a phosphor-virtual-sensor commit.
Example compile failure:
../virtualSensor.cpp:198:33: in ‘constexpr’ expansion of ‘lg2::details::header_str("MESSAGE")’ ../subprojects/phosphor-logging/lib/include/phosphor-logging/lg2/header.hpp:45:25: error: call to non-‘constexpr’ function ‘static void lg2::details::header_str::report_error(const char*)’ 45 | report_error("Header name is reserved.");
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I3a5c21fe25d307bf9b7fd296a71246a76d66872a
show more ...
|
cbdc283c | 02-Aug-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: compile time header format checking
Add support to check the format of message headers at compile time to verify the rules imposed by journald APIs.
Signed-off-by: Patrick Williams <patrick@st
lg2: compile time header format checking
Add support to check the format of message headers at compile time to verify the rules imposed by journald APIs.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I99fcbd8918bbf11ba839843ac8e793d8402b9055
show more ...
|
6b1077f6 | 29-Jul-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: support exception conversion
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I4b3cb55c9d03ed04b1f072bf3f5ef98ccffb0eef |
e43ec443 | 27-Jul-2021 |
Patrick Williams <patrick@stwcx.xyz> |
lg2: support sdbusplus enum conversion
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I78cb28697631499adf5be64f7157a894c8d887ee |
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 |
c28601ad | 29-Jul-2021 |
William A. Kennington III <wak@google.com> |
lib: Change name to accomodate direct linkers
We have some builds that are not using pkgconfig and instead directly linking against the library. This makes the name consistent with the linkers.
Cha
lib: Change name to accomodate direct linkers
We have some builds that are not using pkgconfig and instead directly linking against the library. This makes the name consistent with the linkers.
Change-Id: I3b618d53784a52c8e5dea5857b363961e5216c95 Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|
e0538848 | 11-Jun-2021 |
William A. Kennington III <wak@google.com> |
build: Refactor to separate out library
This makes it more clear what code is intended for use by the phosphor-logging shared library. This is especially nice since it isolates the `phosphor_logging
build: Refactor to separate out library
This makes it more clear what code is intended for use by the phosphor-logging shared library. This is especially nice since it isolates the `phosphor_logging_dep` to only provide the exported headers instead of everything in the project.
Additionally, this adds an option to build only the library components of the project when the services aren't needed.
Change-Id: Ied0858fc70e8054df4c056d91f35a6f0b3acfcb1 Signed-off-by: William A. Kennington III <wak@google.com>
show more ...
|