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

Extend precision of access log "D" to milliseconds #527

Merged
merged 2 commits into from
Sep 24, 2015
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
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