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/meson.build b/lib/meson.build
index 8446767..2679548 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -1,6 +1,19 @@
phosphor_logging_includes = include_directories('include')
-phosphor_logging_gen = []
+event_filter_json = get_option('event-filter')
+if event_filter_json == ''
+ event_filter_json = default_eventfilter_json
+endif
+
+lg2_eventfilter_cpp_gen = custom_target(
+ 'lg2_eventfilter.cpp',
+ input: [eventfilter_gen, template_eventfilter_gen, event_filter_json],
+ output: 'lg2_eventfilter.cpp',
+ command: [python_prog, '@INPUT0@', '@INPUT2@'],
+ capture: true,
+)
+
+phosphor_logging_gen = [lg2_eventfilter_cpp_gen]
subdir('include/phosphor-logging')
@@ -43,4 +56,3 @@
sources: phosphor_logging_gen,
dependencies: phosphor_logging_deps,
)
-