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

Allow ConfigParser or a io.IO[Any] on log_config #1976

Merged
merged 3 commits into from
Apr 13, 2024

Conversation

antonymayi
Copy link
Contributor

@antonymayi antonymayi commented May 13, 2023

This is a new instance of PR #1716 closed accidentally by deleting the forked repository.

Copy of the previous description:

The existing logic for the log_config option accepts:

  • dict or str representing a JSON or YAML file name to be parsed using logging.config.dictConfig
  • str representing an INI file name to be parsed using logging.config.fileConfig

The logging.config.fileConfig, however, accepts not only the file name, but possibly also an instance of configparser.RawConfigParser and even an open file object. Passing the instance of configparser.RawConfigParser (or its subclass) would be especially useful as this can accumulate configs from multiple files (cp.read() can be called repeatedly on different files updating its config values) instead of just a single one.

I am proposing this trivial change to allow the log_config option to also accept the *ConfigParser instance or a general file object.

Copy link
Member

@karpetrosyan karpetrosyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two options, which are listed in the logging documentation, can help with project configuration management

Changed in version 3.4: An instance of a subclass of RawConfigParser is now accepted as a value for fname. This facilitates:

Use of a configuration file where logging configuration is just part of the overall application configuration.

Use of a configuration read from a file, and then modified by the using application (e.g. based on command-line parameters or other aspects of the runtime environment) before being passed to fileConfig.

I like how fileConfig is used in this way.

@Kludex Kludex changed the title Enabled to pass log_config as ConfigParser instance or a file object Allow ConfigParser or a io.IO[Any] on log_config Apr 13, 2024
@Kludex Kludex enabled auto-merge (squash) April 13, 2024 11:48
@Kludex Kludex merged commit 12c9ee3 into encode:master Apr 13, 2024
15 checks passed
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

Successfully merging this pull request may close these issues.

3 participants