From f50a37fc88b8157578787b93391e0054d4d06a82 Mon Sep 17 00:00:00 2001 From: lixxu Date: Tue, 28 Nov 2017 14:44:32 +0800 Subject: [PATCH] ignore error if request.ip is None --- sanic/server.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sanic/server.py b/sanic/server.py index a475fd98..2d11d90f 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -312,13 +312,15 @@ class HttpProtocol(asyncio.Protocol): else: extra['byte'] = -1 + extra['host'] = 'UNKNOWN' if self.request is not None: - extra['host'] = '{0}:{1}'.format(self.request.ip[0], - self.request.ip[1]) + if self.request.ip: + extra['host'] = '{0}:{1}'.format(self.request.ip[0], + self.request.ip[1]) + extra['request'] = '{0} {1}'.format(self.request.method, self.request.url) else: - extra['host'] = 'UNKNOWN' extra['request'] = 'nil' access_logger.info('', extra=extra)