cloud-custodian / cel-python

Pure Python implementation of the Common Expression Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default logging configuration is too noisy, proper way to disable logging in this lib?

falau opened this issue · comments

The default configuration(logger names/logging levels in each module) doesn't seem to be reasonable when using this package as a library. A simple logging.basicConfig(level=logging.INFO) could easily flood the logging output.

I know I can make it less noisy by setting the loggers used in the module individually like logging.getLogger(logger_name).setLevel(some_other_level), but the logger names in this module are not really consistent such as prefixing with a single module name or so, I can only go to the source code to find out all the logger names used rather than adding a prefix filter to disable all loggers in one go:

for _logger_name in ("Evaluator", "evaluation", "NameContainer", "celtypes", "Environment"):
  logging.getLogger(_logger_name).setLevel(logging.WARNING)

This approach doesn't really look sustainable, especially, I can't know if there will be any change, such as new loggers added; old loggers removed, etc., in this module.

Therefore, I'm wondering if it's possible to support one of the followings going forward?

  • Consolidate the logger names into something predictable
  • Add an option to adjust all the loggers used
  • Allow users to pass in loggers
  • others idk

Thank you!

thanks for the bug report, yeah it does seem reasonable to prefix all the loggers here, to make it more ergonomic to switch the level