pgjones / hypercorn

Hypercorn is an ASGI and WSGI Server based on Hyper libraries and inspired by Gunicorn.
MIT License
1.18k stars 105 forks source link

Logging app initialization failure using config.log #218

Open pdelagrave opened 7 months ago

pdelagrave commented 7 months ago

On exiting due to an unhandled exception during the app initialization (lifespan), the process(es) spawned by multiprocessing.BaseContext.Process.start() in _populate() would have their stack traceback directly printed to stderr by BaseProcess:_bootstrap.

Using the user-configurable config.log logger instead makes the log output more consistent.


Notes on the changeset:


Motivation

We're using fastapi/hypercorn in production with structlog and a json formatter so the logs can be ingested by some logs storage and visualization tooling. We've configured everything so the application outputs JSON logs but in the case the app fails to start, hypercorn was outputting a raw stack traceback to stderr, which isn't consistent with how the logging system was configured.

dhirschfeld commented 3 weeks ago

ping!

Also interested in your configuration to enable structlog @pdelagrave, if you're free to share?