tools: add gen-eventfilter.py
Generate event filtering code for lg2::commit from an input json
file, so that system integrators can create default filtering rules
to omit undesired events and errors from their systems.
Tested:
Used `log-create` to create an event and observed it. Modified the
default event filter as follows and saw log was not created.
```
@@ -3,6 +3,9 @@
"default": "allowed"
},
"errors": {
- "default": "allowed"
+ "default": "allowed",
+ "ids": [
+ "xyz.openbmc_project.State.SMC.SMCFailed"
+ ]
}
}
```
```
$ ./builddir/log-create xyz.openbmc_project.State.SMC.SMCFailed --json '{ "IDENTIFIER": "/xyz/openbmc_project/inventory/SomeSMC", "FAILURE_TYPE": "Timeout for the SMC" }'
```
Change-Id: Ib6041481075758b994bb27a816dbf5e9f26c2841
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/lib/lg2_commit.cpp b/lib/lg2_commit.cpp
index a35b91e..a2ceb22 100644
--- a/lib/lg2_commit.cpp
+++ b/lib/lg2_commit.cpp
@@ -117,6 +117,16 @@
auto commit(sdbusplus::exception::generated_event_base&& t)
-> sdbusplus::message::object_path
{
+ // Check event filters first.
+ if ((t.severity() == LOG_INFO) && details::filterEvent(t.name()))
+ {
+ return {};
+ }
+ else if (details::filterError(t.name()))
+ {
+ return {};
+ }
+
if constexpr (LG2_COMMIT_JOURNAL)
{
lg2::error("OPENBMC_MESSAGE_ID={DATA}", "DATA", t.to_json().dump());