示例#1
0
文件: http.py 项目: asavoy/pyrax
def http_log_resp(resp, body):
    """
    When pyrax.get_http_debug() is True, outputs the response received
    from the API request.
    """
    if not pyrax.get_http_debug():
        return
    pyrax._logger.debug("RESP: %s %s\n", resp, body)
示例#2
0
文件: http.py 项目: annegentle/pyrax
def http_log_resp(resp, body):
    """
    When pyrax.get_http_debug() is True, outputs the response received
    from the API request.
    """
    if not pyrax.get_http_debug():
        return
    log = logging.getLogger("pyrax")
    log.debug("RESP: %s %s\n", resp, body)
示例#3
0
文件: http.py 项目: rackspace/pyrax
def http_log_resp(resp, body):
    """
    When pyrax.get_http_debug() is True, outputs the response received
    from the API request.
    """
    if not pyrax.get_http_debug():
        return
    log = logging.getLogger("pyrax")
    log.debug("RESP: %s\n%s", resp, resp.headers)
    if body:
        log.debug("RESP BODY: %s", body)
示例#4
0
文件: http.py 项目: annegentle/pyrax
def http_log_req(method, uri, args, kwargs):
    """
    When pyrax.get_http_debug() is True, outputs the equivalent `curl`
    command for the API request being made.
    """
    if not pyrax.get_http_debug():
        return
    string_parts = ["curl -i -X %s" % method]
    for element in args:
        string_parts.append("%s" % element)
    for element in kwargs["headers"]:
        header = "-H '%s: %s'" % (element, kwargs["headers"][element])
        string_parts.append(header)
    string_parts.append(uri)
    log = logging.getLogger("pyrax")
    log.debug("\nREQ: %s\n" % " ".join(string_parts))
    if "body" in kwargs:
        pyrax._logger.debug("REQ BODY: %s\n" % (kwargs["body"]))
示例#5
0
def http_log_req(method, uri, args, kwargs):
    """
    When pyrax.get_http_debug() is True, outputs the equivalent `curl`
    command for the API request being made.
    """
    if not pyrax.get_http_debug():
        return
    string_parts = ["curl -i -X %s" % method]
    for element in args:
        string_parts.append("%s" % element)
    for element in kwargs["headers"]:
        header = "-H '%s: %s'" % (element, kwargs["headers"][element])
        string_parts.append(header)
    string_parts.append(uri)
    log = logging.getLogger("pyrax")
    log.debug("\nREQ: %s\n" % " ".join(string_parts))
    if "body" in kwargs:
        pyrax._logger.debug("REQ BODY: %s\n" % (kwargs["body"]))
示例#6
0
文件: http.py 项目: asavoy/pyrax
def http_log_req(args, kwargs):
    """
    When pyrax.get_http_debug() is True, outputs the equivalent `curl`
    command for the API request being made.
    """
    if not pyrax.get_http_debug():
        return
    string_parts = ["curl -i"]
    for element in args:
        if element in ("GET", "POST", "PUT", "DELETE", "HEAD", "PATCH"):
            string_parts.append(" -X %s" % element)
        else:
            string_parts.append(" %s" % element)

    for element in kwargs["headers"]:
        header = " -H '%s: %s'" % (element, kwargs["headers"][element])
        string_parts.append(header)

    pyrax._logger.debug("\nREQ: %s\n" % "".join(string_parts))
    if "body" in kwargs:
        pyrax._logger.debug("REQ BODY: %s\n" % (kwargs["body"]))