Skip to content

Commit

Permalink
Merge pull request #527 from sterwill/master
Browse files Browse the repository at this point in the history
Extend precision of access log "D" to milliseconds
  • Loading branch information
asvetlov committed Sep 24, 2015
2 parents 3a01af7 + 583280d commit 92cd425
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def atoms(message, environ, response, transport, request_time):
'f': headers.get(hdrs.REFERER, '-'),
'a': headers.get(hdrs.USER_AGENT, '-'),
'T': str(int(request_time)),
'D': str(request_time).split('.', 1)[-1][:5],
'D': str(request_time).split('.', 1)[-1][:6],
'p': "<%s>" % os.getpid()
}

Expand Down
11 changes: 11 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ def prop(self):
a.prop = 123


class TestAtoms(unittest.TestCase):

def test_get_seconds_and_milliseconds(self):
response = dict(status=200, output_length=1)
request_time = 321.012345678901234

atoms = helpers.atoms(None, None, response, None, request_time)
self.assertEqual(atoms['T'], '321')
self.assertEqual(atoms['D'], '012345')


class TestSafeAtoms(unittest.TestCase):

def test_get_non_existing(self):
Expand Down

0 comments on commit 92cd425

Please sign in to comment.