updated name and added functionality for choosing status codes
@@ -212,13 +212,12 @@ class Response(object):
class HttpTransport(Invoker):
- async def request_handler(cls: Any, obj: Any, context: Dict, func: Any, method: str, url: str, quiet_access: bool = False) -> Any:
+ async def request_handler(cls: Any, obj: Any, context: Dict, func: Any, method: str, url: str, ignore_logging: Union[bool, List[int], Tuple[int]] = False) -> Any:
pattern = r'^{}$'.format(re.sub(r'\$$', '', re.sub(r'^\^?(.*)$', r'\1', url)))
compiled_pattern = re.compile(pattern)
default_content_type = context.get('options', {}).get('http', {}).get('content_type', 'text/plain')
default_charset = context.get('options', {}).get('http', {}).get('charset', 'utf-8')
- context['quiet_access'] = quiet_access
if default_content_type is not None and ";" in default_content_type:
# for backwards compability
@@ -511,7 +510,7 @@ class HttpTransport(Invoker):
return await cls.request_handler(cls, obj, context, _func, 'GET', url)
- async def start_server(obj: Any, context: Dict) -> Optional[Callable]:
+ async def start_server(obj: Any, context: Dict, ignore_logging: Union[bool, List[int], Tuple[int]] = False) -> Optional[Callable]:
if context.get('_http_server_started'):
return None
context['_http_server_started'] = True
@@ -590,7 +589,9 @@ class HttpTransport(Invoker):
if not request._cache.get('is_websocket'):
status_code = response.status if response is not None else 500
- if status_code >= 200 and status_code <= 299 and context.get('quiet_access', False):
+ if ignore_logging is True:
+ pass
+ elif isinstance(ignore_logging, (list, tuple)) and status_code in ignore_logging:
pass
else:
logging.getLogger('transport.http').info('[{}] [{}] {} {} "{} {}{}{}" {} {} "{}" {}'.format(
