Skip to content

Commit

Permalink
Allow run_app(access_log=None) (#3504)
Browse files Browse the repository at this point in the history
* Mark access_log as optional

* Make access_log=None work in debug mode
  • Loading branch information
hynek authored and asvetlov committed Jan 9, 2019
1 parent d487af9 commit c562ffe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/3504.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix type stubs for ``aiohttp.web.run_app(access_log=True)`` and fix edge case of ``access_log=True`` and the event loop being in debug mode.
6 changes: 3 additions & 3 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ async def _run_app(app: Union[Application, Awaitable[Application]], *,
backlog: int=128,
access_log_class: Type[AbstractAccessLogger]=AccessLogger,
access_log_format: str=AccessLogger.LOG_FORMAT,
access_log: logging.Logger=access_logger,
access_log: Optional[logging.Logger]=access_logger,
handle_signals: bool=True,
reuse_address: Optional[bool]=None,
reuse_port: Optional[bool]=None) -> None:
Expand Down Expand Up @@ -383,15 +383,15 @@ def run_app(app: Union[Application, Awaitable[Application]], *,
backlog: int=128,
access_log_class: Type[AbstractAccessLogger]=AccessLogger,
access_log_format: str=AccessLogger.LOG_FORMAT,
access_log: logging.Logger=access_logger,
access_log: Optional[logging.Logger]=access_logger,
handle_signals: bool=True,
reuse_address: Optional[bool]=None,
reuse_port: Optional[bool]=None) -> None:
"""Run an app locally"""
loop = asyncio.get_event_loop()

# Configure if and only if in debugging mode and using the default logger
if loop.get_debug() and access_log.name == 'aiohttp.access':
if loop.get_debug() and access_log and access_log.name == 'aiohttp.access':
if access_log.level == logging.NOTSET:
access_log.setLevel(logging.DEBUG)
if not access_log.hasHandlers():
Expand Down

0 comments on commit c562ffe

Please sign in to comment.