From 6abdf9f9c162140a4981c21361d334323ed47d65 Mon Sep 17 00:00:00 2001 From: hqy Date: Thu, 16 Aug 2018 01:23:04 +0800 Subject: [PATCH] fixed #1143 (#1276) * fixed #1143 * fixed build failed with create_serve call _helper failed --- sanic/app.py | 16 ++++++++-------- sanic/config.py | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sanic/app.py b/sanic/app.py index e82028f4..367acc5a 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -688,11 +688,12 @@ class Sanic: warnings.simplefilter('default') warnings.warn("stop_event will be removed from future versions.", DeprecationWarning) + # compatibility old access_log params + self.config.ACCESS_LOG = access_log server_settings = self._helper( host=host, port=port, debug=debug, ssl=ssl, sock=sock, workers=workers, protocol=protocol, backlog=backlog, - register_sys_signals=register_sys_signals, - access_log=access_log, auto_reload=auto_reload) + register_sys_signals=register_sys_signals, auto_reload=auto_reload) try: self.is_running = True @@ -746,12 +747,12 @@ class Sanic: warnings.simplefilter('default') warnings.warn("stop_event will be removed from future versions.", DeprecationWarning) - + # compatibility old access_log params + self.config.ACCESS_LOG = access_log server_settings = self._helper( host=host, port=port, debug=debug, ssl=ssl, sock=sock, loop=get_event_loop(), protocol=protocol, - backlog=backlog, run_async=True, - access_log=access_log) + backlog=backlog, run_async=True) # Trigger before_start events await self.trigger_events( @@ -796,8 +797,7 @@ class Sanic: def _helper(self, host=None, port=None, debug=False, ssl=None, sock=None, workers=1, loop=None, protocol=HttpProtocol, backlog=100, stop_event=None, - register_sys_signals=True, run_async=False, access_log=True, - auto_reload=False): + register_sys_signals=True, run_async=False, auto_reload=False): """Helper function used by `run` and `create_server`.""" if isinstance(ssl, dict): # try common aliaseses @@ -838,7 +838,7 @@ class Sanic: 'loop': loop, 'register_sys_signals': register_sys_signals, 'backlog': backlog, - 'access_log': access_log, + 'access_log': self.config.ACCESS_LOG, 'websocket_max_size': self.config.WEBSOCKET_MAX_SIZE, 'websocket_max_queue': self.config.WEBSOCKET_MAX_QUEUE, 'websocket_read_limit': self.config.WEBSOCKET_READ_LIMIT, diff --git a/sanic/config.py b/sanic/config.py index 8e1f383c..c5e42de5 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -39,6 +39,7 @@ class Config(dict): self.WEBSOCKET_READ_LIMIT = 2 ** 16 self.WEBSOCKET_WRITE_LIMIT = 2 ** 16 self.GRACEFUL_SHUTDOWN_TIMEOUT = 15.0 # 15 sec + self.ACCESS_LOG = True if load_env: prefix = SANIC_PREFIX if load_env is True else load_env