1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 09:18:08 +00:00

Fix log with recent aiohttp versions

This commit is contained in:
Julien Duponchelle 2016-03-31 18:03:40 +02:00
parent e097a0e728
commit 34459f6a88
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D

View File

@ -18,6 +18,7 @@
import json
import jsonschema
import aiohttp.web
import asyncio
import logging
import sys
import jinja2
@ -41,7 +42,8 @@ class Response(aiohttp.web.Response):
headers['Server'] = "Python/{0[0]}.{0[1]} GNS3/{1}".format(sys.version_info, __version__)
super().__init__(headers=headers, **kwargs)
def start(self, request):
@asyncio.coroutine
def prepare(self, request):
if log.getEffectiveLevel() == logging.DEBUG:
log.info("%s %s", request.method, request.path_qs)
log.debug("%s", dict(request.headers))
@ -51,7 +53,7 @@ class Response(aiohttp.web.Response):
log.debug(dict(self.headers))
if hasattr(self, 'body') and self.body is not None and self.headers["CONTENT-TYPE"] == "application/json":
log.debug(json.loads(self.body.decode('utf-8')))
return super().start(request)
return (yield from super().prepare(request))
def html(self, answer):
"""