I want to add logging to my Python hug REST app. I couldn't find any wayto do it when serving the app through the hug
command (via hug -f app.py
), therefore I try to combine hug with waitress.
My minimal app structure in the file app.py
looks like:
import logging
logger = logging.getLogger(__name__)
import hug
.
.
.
@hug.get()
def func(detail):
logger.debug("debug func")
.
.
.
And I serve this with a waitress script run.py
:
import logging
import waitress
import app
logger = logging.getLogger('waitress')
logger.setLevel(logging.DEBUG)
logger.debug("logger set to DEBUG")
waitress.serve(app.__hug_wsgi__)
When I execute python run.py
in a console, the app spins up nicely and the results of func
are served back, however the debug messages from inside func ("debug func") and from run.py
("logger set to DEBUG") I cannot see in the console.
What is going wrong and how can I fix it? (I'm happy to use another (Windows-capable) WSGI server if that's easier.)