Archipelago
Archipelago copied to clipboard
WebHost: Bug: console log is suppressed when any keys are missing from options.yaml
What happened?
git clonethe repo- Optional: create virtualenv
- Copy
host.yaml->options.yaml - Remove any line from your now customized
options.yaml python WebHost.py
Bug: The log message that you are hosting on 0.0.0.0:
This bug was introduced by commit 4a2a184 ("Core: remove game-specific arguments from Generate (#971)", 2 days ago).
What were the expected results?
Expected: Logging to console works
Software
Local generation
Analysis
Per debugger, here's what's going on.
- LTTP world init new behavior in 4a2a184: calls
Utils.get_options()as soon as LTTP world is imported Utils.get_optionswrites a scary log message usinglogging.infoif the yaml file that Utils chose to read (in this case, options.yaml; host.yaml is ignored) is missing any key that's present in the fixed/const dict returned byUtils.get_default_options()(which is almost identical to host.yaml, incidentally). This log message never reaches the console.- After all of its imports, WebHost.py then runs
logging.basicConfig(..., level=logging.INFO) - As part of
logging.basicConfig, because a log message was already emitted,/usr/lib/python3.10/logging/__init__.pyhad to go ahead and initialize a log handler already at the time of the log message. Therefore, now when we intentionally request to configure the log,loggingignores the request since it has already been set up.
Solution: black-sliver has suggested:
- initializing logging earlier in WebHost.py; and
- calling
logging.basicConfig(..., force=True); and - redirecting all log statements that may occur at init time to a new wrapper so that they can be handled appropriately.
@black-sliver I suspect this is fixed now?