Python Custom Logging Filter

Preamble

I used this blog post as the foundation for creating a custom logging filter. In order to have better control in the granularity of the filter, I wrote this setup for filtering on multiple attributes (currently: calling module, message, log level). The query goes in the value for the appropriate key in filter_config.json. It’s fairly trivial to add another attribute, to do so:

  • Add the filter query to filter_config.json
  • Create a filter function in filter.py
  • Add the filter function to the filter_map (the switch/case workaround)

Code

Leave a Reply

Your email address will not be published. Required fields are marked *