-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notion of generic formatters/formatter factories
Add the notion of "generic" event formatters and formatter factories that can create a formatter for a given format string: - gen_filter.h defines two new classes: gen_event_formatter provides the interface to format events: - set_format(): set the output format and format string - tostring(): resolve the format with info from a gen_event, populating a resolved string. - tostring_withformat(): like tostring() but with a one-off output format. - get_field_values(): return all templated field names and values from the configured format string. - get_output_format(): get the current output format. - gen_event_formatter_factory performs a similar role as the existing sinsp_evt_formatter_cache, in that it maintains a cache of previously used format strings/formatters, to avoid the overhead of creating formatters. It simply returns a formatter, though, rather than duplicating the format methods like sinsp_evt_formatter_cache does. This can be used in programs like falco to format general purpose events without having a direct connection to an inspector/filterchecks/etc. - The eventformatter changes simply add gen_event_formatter as a parent class and implements the interfaces. To aid in backwards compatibility with other parts of libsinsp, this only adds new methods as needed to conform to the gen_event_formatter interface. In some cases, the new methods just call existing methods that did the same thing. Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
- Loading branch information
Showing
4 changed files
with
196 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters