pypa / bandersnatch

A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/
Academic Free License v3.0
448 stars 141 forks source link

Setting log-config option in config errors about formatters #1090

Open cooperlees opened 2 years ago

cooperlees commented 2 years ago

Running with the 1log-config` setting we currently crash. Example config:

[mirror]
...
log-config = /data/pip/bandersnatch-log.conf
...

Causes:

crl-m1:bandersnatch cooper$ /tmp/tb/bin/bandersnatch --debug -c /tmp/bandersnatch.conf mirror 2>&1 | tee /tmp/bandersnatch_run_1
Traceback (most recent call last):
  File "/tmp/tb/bin/bandersnatch", line 8, in <module>
    sys.exit(main())
  File "/private/tmp/tb/lib/python3.9/site-packages/bandersnatch/main.py", line 215, in main
    logging.config.fileConfig(str(Path(config.get("mirror", "log-config"))))
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/logging/config.py", line 71, in fileConfig
    formatters = _create_formatters(cp)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/logging/config.py", line 104, in _create_formatters
[mirror]
    flist = cp["formatters"]["keys"]
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/configparser.py", line 963, in __getitem__
    raise KeyError(key)
KeyError: 'formatters'
cooperlees commented 2 years ago

I came back to look at this to land - But this didn't ned a fix, this option requires a valid Python logging ini config, so it

I will take a PR making the logging clearer or something here. But putting low priority for me at the moment.