def log_request(handler):
    """log a bit more information about each request than tornado's default
    
    - move static file get success to debug-level (reduces noise)
    - get proxied IP instead of proxy IP
    - log referer for redirect and failed requests
    - log user-agent for failed requests
    """
    status = handler.get_status()
    request = handler.request
    if status == 304 or (status < 300 and isinstance(handler, StaticFileHandler)):
        # static-file success and 304 Found are debug-level
        log_method = access_log.debug
    elif 400 < status:
        log_method = access_log.info
    elif status < 500:
        log_method = access_log.warning
    else:
        log_method = access_log.error
    
    uri = _scrub_uri(request.uri)
    headers = _scrub_headers(request.headers)
    
    request_time = 1000.0 * handler.request.request_time()
    user = handler.get_current_user()
    ns = dict(
        status=status,
        method=request.method,
        ip=request.remote_ip,
        uri=uri,
        request_time=request_time,
        user=user.name if user else ''
    )
    msg = "{status} {method} {uri} ({user}@{ip}) {request_time:.2f}ms"
    if status >= 500 and status != 502:
        log_method(json.dumps(headers, indent=2))
    log_method(msg.format(**ns))
dataset/ETHPy150Open jupyterhub/jupyterhub/jupyterhub/log.py/log_request/swapped operands of `<`