Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate dictionaries passed to dictConfig #16

Open
adamchainz opened this issue Aug 24, 2023 · 1 comment
Open

Validate dictionaries passed to dictConfig #16

adamchainz opened this issue Aug 24, 2023 · 1 comment

Comments

@adamchainz
Copy link
Owner

Description

Calls to logging.config.dictConfig should follow a schema defined in the docs: https://docs.python.org/3/library/logging.config.html#dictionary-schema-details

Perhaps this plugin can do some fast-and-cheap validation against this schema to prevent common issues, such as missing the version key.

Django’s LOGGING setting is also passed to dictConfig, if LOGGING_CONFIG is unchanged, so we may be able to validate that too.

@adamchainz adamchainz changed the title Validate dictinoary configs Validate dictionaries passed to dictConfig Aug 24, 2023
@adamchainz
Copy link
Owner Author

Potential checks:

  1. version required, set to 1
  2. Bad capitalization of keys, like “Formatters” instead of “formatters”.
  3. Typos in key names, like “formatter” instead of “formatters”. (using difflib.get_close_matches)
  4. If incremental is True, formatters and filters are ignored.
  5. logger.handlers referring to nonexistent handlers.
  6. handlers.filters referring to nonexistent filters.
  7. logger.level not being in defined names: INFO, WARNING, etc. Use get_close_matches again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant