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
Sane default for logging config #65694
Comments
Imagine you write a small console script which is implemented like a library. This tool has to do two things: the console script needs to configure the logging, and the library needs to use it. The library usage of logging it easy well documented: {{{ But the part in the console script has no sane default in the python world. I know how to set up the logging config with BasicConfig, DictConfig, ... There needs to be something like DefaultConfig() which reads its config from well known places. This bug report is not about clever code solutions. It is about a sane and easy default agreement on how to load the logging configuration. |
Who decides what's sane and what isn't? You seem to be asking for something, but you don't seem to have a concrete proposal. Are there "sane" defaults in other worlds than the Python world? What are they? |
Thank you for reading and replying. Yes, I wrote no concret proposal up to now. I have this solutions in mind: logging.config.defaultConfig() Related https://docs.python.org/2/library/logging.config.html Loading a python module: load a module "loggingconfig" this module gets imported like any other python module. It is like django loads its settings. It could be possible to check the environment variable LOGGINGCONFIG first. It could contain a string which defaults to "loggingconfig". This module has a method "set_up()" which sets up the logging for this environment. Loading from a file: A file searched in this places:
The file gets loaded with fileConfig() Module or file config loading I think the module loading is better than the file based solution. That's why I think it should be done first. If there is no module found, the file loading should be tried. If not config found If not config was found, default gets set. My proposal:
--------------------------- What is the best way to get this into the python standard library? Should I create a PEP? |
Just on backward compatibility grounds, a proposal like this isn't going to be acceptable on python-dev, I believe, and I'm not even sure it's necessary to have such a thing in the stdlib: why not just use the approach you suggested for your own projects, and leave it at that? I've certainly found that preferences for configuration approaches vary a lot across people, and nothing will please everyone :-( Generally, before writing a PEP, ideas are broached on the python-ideas mailing list, then move to the python-dev mailing list when they seem to have enough mileage to do so, and the PEP discussion / life-cycle happens there. |
FWIW, I agree with Vinay. |
Moving discussion to python-ideas was the right thing to do. I am closing this for the present as there is no concrete accepted idea to write a patch for. Thomas, if that changes, you can re-open. |
Just for the record. Here are the discussions about this topic on the python-ideas mailing list: https://mail.python.org/pipermail/python-ideas/2014-May/027839.html https://mail.python.org/pipermail/python-ideas/2014-May/027858.html |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: