Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3158 - Support overriding access_log_class with handler_args #3262

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/3158.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable passing `access_log_class` via `handler_args`
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ Taras Voinarovskyi
Terence Honles
Thanos Lefteris
Thijs Vermeir
Thomas Forbes
Thomas Grainger
Tolga Tezel
Trinh Hoang Nhu
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@ def _make_handler(self, *,
self.freeze()

kwargs['debug'] = self.debug
kwargs['access_log_class'] = access_log_class
if self._handler_args:
for k, v in self._handler_args.items():
kwargs[k] = v

return Server(self._handle, request_factory=self._make_request,
access_log_class=access_log_class,
loop=self.loop, **kwargs)

def make_handler(self, *,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def log(self, request, response, time):
request_factory=app._make_request,
loop=loop, debug=mock.ANY)

app = web.Application(handler_args={'access_log_class': Logger})
app._make_handler(access_log_class=Logger, loop=loop)
srv.assert_called_with(app._handle,
access_log_class=Logger,
request_factory=app._make_request,
loop=loop, debug=mock.ANY)


def test_app_make_handler_raises_deprecation_warning(loop):
app = web.Application()
Expand Down