fix debug mode in gaiohttp worker

The debug setting has been removed and now only the debug level can be used to know if
we are in debug mode or not. This change update the gaiohttp worker to handle
that. While I'm here, expose the loglevel from the Logger class.

fix #977
This commit is contained in:
benoitc 2015-02-04 10:07:18 +01:00
parent d8eca3ebf1
commit 8b6d86ef2b
2 changed files with 8 additions and 3 deletions

View File

@ -171,12 +171,13 @@ class Logger(object):
self.access_log.propagate = False
self.error_handlers = []
self.access_handlers = []
self.loglevel = logging.INFO
self.cfg = cfg
self.setup(cfg)
def setup(self, cfg):
loglevel = self.LOG_LEVELS.get(cfg.loglevel.lower(), logging.INFO)
self.error_log.setLevel(loglevel)
self.loglevel = self.LOG_LEVELS.get(cfg.loglevel.lower(), logging.INFO)
self.error_log.setLevel(self.loglevel)
self.access_log.setLevel(logging.INFO)
# set gunicorn.error handler

View File

@ -5,6 +5,7 @@
import asyncio
import functools
import logging
import os
import gunicorn.workers.base as base
@ -44,11 +45,14 @@ class AiohttpWorker(base.Worker):
return proto
def factory(self, wsgi, addr):
# are we in debug level
is_debug = self.log.loglevel == logging.DEBUG
proto = WSGIServerHttpProtocol(
wsgi, readpayload=True,
loop=self.loop,
log=self.log,
debug=self.cfg.debug,
debug=is_debug,
keep_alive=self.cfg.keepalive,
access_log=self.log.access_log,
access_log_format=self.cfg.access_log_format)