本文整理汇总了Python中gunicorn.glogging.Logger.atoms方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.atoms方法的具体用法?Python Logger.atoms怎么用?Python Logger.atoms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gunicorn.glogging.Logger
的用法示例。
在下文中一共展示了Logger.atoms方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_atoms_defaults
# 需要导入模块: from gunicorn.glogging import Logger [as 别名]
# 或者: from gunicorn.glogging.Logger import atoms [as 别名]
def test_atoms_defaults():
response = Mock(status='200', response_length=1024,
headers=(('Content-Type', 'application/json'), ))
request = Mock(headers=(('Accept', 'application/json'), ))
environ = {'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri',
'SERVER_PROTOCOL': 'HTTP/1.1'}
logger = Logger(Config())
atoms = logger.atoms(response, request, environ,
datetime.timedelta(seconds=1))
t.istype(atoms, dict)
t.eq(atoms['r'], 'GET http://my.uri HTTP/1.1')
t.eq(atoms['{accept}i'], 'application/json')
t.eq(atoms['{content-type}o'], 'application/json')
示例2: test_get_username_from_basic_auth_header
# 需要导入模块: from gunicorn.glogging import Logger [as 别名]
# 或者: from gunicorn.glogging.Logger import atoms [as 别名]
def test_get_username_from_basic_auth_header():
request = SimpleNamespace(headers=())
response = SimpleNamespace(
status='200', response_length=1024, sent=1024,
headers=(('Content-Type', 'text/plain'),),
)
environ = {
'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri',
'SERVER_PROTOCOL': 'HTTP/1.1',
'HTTP_AUTHORIZATION': 'Basic YnJrMHY6',
}
logger = Logger(Config())
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
assert atoms['u'] == 'brk0v'
示例3: test_atoms_zero_bytes
# 需要导入模块: from gunicorn.glogging import Logger [as 别名]
# 或者: from gunicorn.glogging.Logger import atoms [as 别名]
def test_atoms_zero_bytes():
response = SimpleNamespace(
status='200', response_length=0,
headers=(('Content-Type', 'application/json'),), sent=0,
)
request = SimpleNamespace(headers=(('Accept', 'application/json'),))
environ = {
'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar',
'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar',
'SERVER_PROTOCOL': 'HTTP/1.1',
}
logger = Logger(Config())
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
assert atoms['b'] == '0'
assert atoms['B'] == 0
示例4: test_atoms_defaults
# 需要导入模块: from gunicorn.glogging import Logger [as 别名]
# 或者: from gunicorn.glogging.Logger import atoms [as 别名]
def test_atoms_defaults():
response = SimpleNamespace(
status='200', response_length=1024,
headers=(('Content-Type', 'application/json'),), sent=1024,
)
request = SimpleNamespace(headers=(('Accept', 'application/json'),))
environ = {
'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri',
'SERVER_PROTOCOL': 'HTTP/1.1',
}
logger = Logger(Config())
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
assert isinstance(atoms, dict)
assert atoms['r'] == 'GET http://my.uri HTTP/1.1'
assert atoms['{accept}i'] == 'application/json'
assert atoms['{content-type}o'] == 'application/json'
示例5: test_get_username_handles_malformed_basic_auth_header
# 需要导入模块: from gunicorn.glogging import Logger [as 别名]
# 或者: from gunicorn.glogging.Logger import atoms [as 别名]
def test_get_username_handles_malformed_basic_auth_header():
"""Should catch a malformed auth header"""
request = SimpleNamespace(headers=())
response = SimpleNamespace(
status='200', response_length=1024, sent=1024,
headers=(('Content-Type', 'text/plain'),),
)
environ = {
'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar',
'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar',
'SERVER_PROTOCOL': 'HTTP/1.1',
'HTTP_AUTHORIZATION': 'Basic ixsTtkKzIpVTncfQjbBcnoRNoDfbnaXG',
}
logger = Logger(Config())
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
assert atoms['u'] == '-'
示例6: test_atoms_defaults
# 需要导入模块: from gunicorn.glogging import Logger [as 别名]
# 或者: from gunicorn.glogging.Logger import atoms [as 别名]
def test_atoms_defaults():
response = SimpleNamespace(
status='200', response_length=1024,
headers=(('Content-Type', 'application/json'),), sent=1024,
)
request = SimpleNamespace(headers=(('Accept', 'application/json'),))
environ = {
'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar',
'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar',
'SERVER_PROTOCOL': 'HTTP/1.1',
}
logger = Logger(Config())
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
assert isinstance(atoms, dict)
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['{content-type}o'] == 'application/json'