-
-
Notifications
You must be signed in to change notification settings - Fork 757
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 .json or .yaml --log-config files #665
Conversation
This adds support for `.json` and `.yaml` config files when running `uvicorn` from the CLI. This allows clients to define how they wish to deal with existing loggers (#511, #512) by providing`disable_existing_loggers` in their config file (the last item described in [this section](https://docs.python.org/3/library/logging.config.html#dictionary-schema-details)). Furthermore, it addresses the desire to allow users to replicate the default hard-coded `LOGGING_CONFIG` in their own configs and tweak it as necessary, something that is not currently possible for clients that wish to run their apps from the CLI.
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.
This allows users to define how they wish to deal with existing loggers (#511, #512)
by providingdisable_existing_loggers in their config file (the last item described in this section.
I may be off on this but I thought that it was not possible to add that key to an ini file and that the only option if you want that behaviour was to pass it as a kwarg to fileConfig(), I don't think this PR solves anything from #511 but I admit I'm not sure about it, if it does it's cool.
otherwise LGTM minus few changes and @tomchristie thoughts on the extra_requires
thing !
You're correct that it's not possible to disable existing loggers with a setting in the |
@tomchristie @euri10 Can we merge this? I've backed out the changes that related to the "extras" decision. As it's implemented now, it expects the user to install a |
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.
Some minor changes to be made I think, my fault because it's been a while since you posted this, I hope you dont mind, let me know if you want me to take this on
- the
pip install uvicorn[yamllogconfig]
is obsolete in settings.md - we would need a section in the README.md about this, after the
python-dotenv
part this should do it - add pyyaml in the setup.py so that we have it when using
uvicorn[standard]
otherwise this is great stuff
docs/settings.md
Outdated
* If you wish to use a YAML file for your logging config, you will want to specify the optional `yamllogconfig` dependency to ensure YAML support: | ||
|
||
``` | ||
$ pip install uvicorn[yamllogconfig] | ||
``` | ||
|
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.
sorry to get back on this that late :) time flies, work is insane,
we can remove this part now package install is merged
I pushed https://github.com/euri10/uvicorn/tree/jcwilson-master based on your work and making the changes so that it doesnt clash with latest master here @jcwilson |
Sorry for not getting back to you earlier last week. I think I've made all the changes you've requested. Let me know if there's anything else and I should be able to address it tomorrow. Thanks! |
thanks for your contribution @jcwilson this is a great addition 💯 ! |
This adds support for
.json
and.yaml
config files when runninguvicorn
from the CLI.This allows users to define how they wish to deal with existing loggers (#511, #512)
by providing
disable_existing_loggers
in their config file (the last item described in this section).Furthermore, it addresses the desire to allow users to replicate the default hard-coded
LOGGING_CONFIG
in their own configs and tweak it as necessary, something that is not currentlypossible for clients that wish to run their apps from the CLI.