Skip to content

Commit

Permalink
Do not fail logging if message is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jun 3, 2016
1 parent 0c912be commit 093d0b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def _format_e(key, args):

@staticmethod
def _format_i(key, args):
return args[0].headers.get(multidict.upstr(key), '-')
return args[0].headers.get(multidict.upstr(key), '-') if args[0] else '(no headers)'

@staticmethod
def _format_o(key, args):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def test_logger_no_message_and_environ():
mock_logger = mock.Mock()
mock_transport = mock.Mock()
mock_transport.get_extra_info.return_value = ("127.0.0.3", 0)
access_logger = helpers.AccessLogger(mock_logger, "%r %{FOOBAR}e")
access_logger = helpers.AccessLogger(mock_logger, "%r %{FOOBAR}e %{content-type}i")
access_logger.log(None, None, None, mock_transport, 0.0)
mock_logger.info.assert_called_with("- -")
mock_logger.info.assert_called_with("- - (no headers)")


def test_reify():
Expand Down

0 comments on commit 093d0b9

Please sign in to comment.