History log of /openbmc/phosphor-logging/log_create_main.cpp (Results 1 – 2 of 2)
Revision Date Author Comments
# fc14867b 06-Nov-2024 Patrick Williams <patrick@stwcx.xyz>

lg2: commit: simplify commit functions

Eliminate the template indirection for the commit function in favor
of a base-class overload. There was previously a public template
specialization of `lg2::c

lg2: commit: simplify commit functions

Eliminate the template indirection for the commit function in favor
of a base-class overload. There was previously a public template
specialization of `lg2::commit` and a private base-class implementation
(in the `details` namespace). The template implementations provided
no stronger type-checking, since it was already a concept requiring
inheritance from the base-class. The template precluded simple code
such as:

```cpp
try
{
//...
}
catch (const sdbusplus::exception::generated_event_base& e)
{
lg2::commit(e);
}
```

By making the base-class types public, rather than hidden in the
details namespace, and removing the templates, the code is simpler
and more usable.

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

show more ...


# dc35e307 05-Nov-2024 Patrick Williams <patrick@stwcx.xyz>

log-create: add CLI utility to create events

Add utility to allow creation of events from the command line and
shell scripts. The utility ensures that the correct data arguments
are passed, or else

log-create: add CLI utility to create events

Add utility to allow creation of events from the command line and
shell scripts. The utility ensures that the correct data arguments
are passed, or else fails the creation.

Tested:

```
$ ./builddir/log-create xyz.openbmc_project.Sensor.Threshold.SensorFailure --json '{ "SENSOR_NAME": "Example-Sensor" }'
<3> OPENBMC_MESSAGE_ID={"xyz.openbmc_project.Sensor.Threshold.SensorFailure":{"SENSOR_NAME":"Example-Sensor","_SOURCE":{"COLUMN":45,"FILE":"../log_create_main.cpp","FUNCTION":"int generate_event(const std::string&, const nlohmann::json_abi_v3_11_2::json&)","LINE":34,"PID":264326}}}
/xyz/openbmc_project/logging/entry/1

$ busctl --user introspect xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/1 -l | cat
xyz.openbmc_project.Logging.Entry interface - - -
.AdditionalData property as 5 "SENSOR_NAME=\"Example-Sensor\"" "_CODE_FILE=../log_create_main.cpp" "_CODE_FUNC=int generate_event(const std::string&, const nlohmann::json_abi_v3_11_2::json&)" "_CODE_LINE=34" "_PID=264326" emits-change writable
.Id property u 1 emits-change writable
.Message property s "xyz.openbmc_project.Sensor.Threshold.SensorFailure" emits-change writable
.Severity property s "xyz.openbmc_project.Logging.Entry.Level.Critical" emits-change writable

$ ./builddir/log-create xyz.openbmc_project.Sensor.Threshold.SensorFailure
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_2::detail::out_of_range'
what(): [json.exception.out_of_range.403] key 'SENSOR_NAME' not found

$ ./builddir/log-create xyz.openbmc_project.Invalid.Event.Name
Unknown event: xyz.openbmc_project.Invalid.Event.Name
```

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

show more ...