mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Add accesslog params
Fix KeyError Update access logger tests Update settings.rst docs
This commit is contained in:
parent
9158ab20f8
commit
7dd8a53c8c
@ -475,8 +475,13 @@ l ``'-'``
|
|||||||
u currently ``'-'``, may be user name in future releases
|
u currently ``'-'``, may be user name in future releases
|
||||||
t date of the request
|
t date of the request
|
||||||
r status line (e.g. ``GET / HTTP/1.1``)
|
r status line (e.g. ``GET / HTTP/1.1``)
|
||||||
|
m request method
|
||||||
|
U URL path without query string
|
||||||
|
q query string
|
||||||
|
H protocol
|
||||||
s status
|
s status
|
||||||
b response length or ``'-'``
|
B response length
|
||||||
|
b response length or ``'-'`` (CLF format)
|
||||||
f referer
|
f referer
|
||||||
a user agent
|
a user agent
|
||||||
T request time in seconds
|
T request time in seconds
|
||||||
|
|||||||
@ -1052,8 +1052,13 @@ class AccessLogFormat(Setting):
|
|||||||
u currently ``'-'``, may be user name in future releases
|
u currently ``'-'``, may be user name in future releases
|
||||||
t date of the request
|
t date of the request
|
||||||
r status line (e.g. ``GET / HTTP/1.1``)
|
r status line (e.g. ``GET / HTTP/1.1``)
|
||||||
|
m request method
|
||||||
|
U URL path without query string
|
||||||
|
q query string
|
||||||
|
H protocol
|
||||||
s status
|
s status
|
||||||
b response length or ``'-'``
|
B response length
|
||||||
|
b response length or ``'-'`` (CLF format)
|
||||||
f referer
|
f referer
|
||||||
a user agent
|
a user agent
|
||||||
T request time in seconds
|
T request time in seconds
|
||||||
|
|||||||
@ -245,7 +245,12 @@ class Logger(object):
|
|||||||
'r': "%s %s %s" % (environ['REQUEST_METHOD'],
|
'r': "%s %s %s" % (environ['REQUEST_METHOD'],
|
||||||
environ['RAW_URI'], environ["SERVER_PROTOCOL"]),
|
environ['RAW_URI'], environ["SERVER_PROTOCOL"]),
|
||||||
's': status,
|
's': status,
|
||||||
|
'm': environ.get('REQUEST_METHOD'),
|
||||||
|
'U': environ.get('PATH_INFO'),
|
||||||
|
'q': environ.get('QUERY_STRING'),
|
||||||
|
'H': environ.get('SERVER_PROTOCOL'),
|
||||||
'b': resp.sent and str(resp.sent) or '-',
|
'b': resp.sent and str(resp.sent) or '-',
|
||||||
|
'B': resp.sent,
|
||||||
'f': environ.get('HTTP_REFERER', '-'),
|
'f': environ.get('HTTP_REFERER', '-'),
|
||||||
'a': environ.get('HTTP_USER_AGENT', '-'),
|
'a': environ.get('HTTP_USER_AGENT', '-'),
|
||||||
'T': request_time.seconds,
|
'T': request_time.seconds,
|
||||||
|
|||||||
@ -13,13 +13,20 @@ def test_atoms_defaults():
|
|||||||
)
|
)
|
||||||
request = SimpleNamespace(headers=(('Accept', 'application/json'),))
|
request = SimpleNamespace(headers=(('Accept', 'application/json'),))
|
||||||
environ = {
|
environ = {
|
||||||
'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri',
|
'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar',
|
||||||
|
'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar',
|
||||||
'SERVER_PROTOCOL': 'HTTP/1.1',
|
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||||
}
|
}
|
||||||
logger = Logger(Config())
|
logger = Logger(Config())
|
||||||
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
|
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
|
||||||
assert isinstance(atoms, dict)
|
assert isinstance(atoms, dict)
|
||||||
assert atoms['r'] == 'GET http://my.uri HTTP/1.1'
|
assert atoms['r'] == 'GET /my/path?foo=bar HTTP/1.1'
|
||||||
|
assert atoms['m'] == 'GET'
|
||||||
|
assert atoms['U'] == '/my/path'
|
||||||
|
assert atoms['q'] == 'foo=bar'
|
||||||
|
assert atoms['H'] == 'HTTP/1.1'
|
||||||
|
assert atoms['b'] == '1024'
|
||||||
|
assert atoms['B'] == 1024
|
||||||
assert atoms['{accept}i'] == 'application/json'
|
assert atoms['{accept}i'] == 'application/json'
|
||||||
assert atoms['{content-type}o'] == 'application/json'
|
assert atoms['{content-type}o'] == 'application/json'
|
||||||
|
|
||||||
@ -31,7 +38,8 @@ def test_get_username_from_basic_auth_header():
|
|||||||
headers=(('Content-Type', 'text/plain'),),
|
headers=(('Content-Type', 'text/plain'),),
|
||||||
)
|
)
|
||||||
environ = {
|
environ = {
|
||||||
'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri',
|
'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar',
|
||||||
|
'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar',
|
||||||
'SERVER_PROTOCOL': 'HTTP/1.1',
|
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||||
'HTTP_AUTHORIZATION': 'Basic YnJrMHY6',
|
'HTTP_AUTHORIZATION': 'Basic YnJrMHY6',
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user