-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Allowing log_config to accept ConfigParser instance or a file object #1716
Conversation
I didn't even know about Anyway... Can you show me an example on how you use this? A self-contained repository that uses this branch is enough. Also, we need to add a test for it. 👀 |
re the usage example: I use It would be convenient to be able to pass that instance to the uvicorn setup as shown here (working example based on my PR). I've updated the PR with the |
Hi @Kludex, happy to update the PR based on your further guidelines in case you have any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this! 👍
Is there any big project that uses |
Depends on the definition of a big project but I believe Apache Airflow for instance should be a fit beyond any doubt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the amount of work needed for you if this PR is not accepted?
Making my life better or worse shouldn't be the concern here (even though I appreciate the consideration). Can you please briefly clarify your reservations about this feature? Do you see any issues or do you just think it is a marginal use case and hence not worth it? The way I see it, this really makes it way easier to integrate Had |
I accidentally deleted the forked repository which automatically closed this PR. I am opening a new one as #1976, apologies for the inconvenience. |
The existing logic for the
log_config
option accepts:dict
orstr
representing a JSON or YAML file name to be parsed usinglogging.config.dictConfig
str
representing an INI file name to be parsed usinglogging.config.fileConfig
The
logging.config.fileConfig
, however, accepts not only the file name, but possibly also an instance ofconfigparser.RawConfigParser
and even an open file object. Passing the instance ofconfigparser.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.