How to use the logentries.le.Domain.API function in Logentries

To help you get started, we’ve selected a few Logentries examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LogentriesCommunity / le_openshift / logentries / le.py View on Github external
def api_request(request, required=False, check_status=False, silent=False, die_on_error=True):
    """
    Processes a request on the logentries domain.
    """
    # Obtain response
    response, conn = get_response(
        "POST", LE_SERVER_API, urllib.urlencode(request),
        silent=silent, die_on_error=die_on_error, domain=Domain.API,
        headers={'Content-Type': 'application/x-www-form-urlencoded'})

    # Check the response
    if not response:
        if required:
            die("Error: Cannot process LE request, no response")
        if conn:
            conn.close()
        return None
    if response.status != 200:
        if required:
            die("Error: Cannot process LE request: (%s)" % response.status)
        conn.close()
        return None

    xresponse = response.read()
github LogentriesCommunity / le_openshift / logentries / le.py View on Github external
def get_response(operation, addr, data=None, headers={}, silent=False, die_on_error=True, domain=Domain.API):
    """
    Returns response from the domain or API server.
    """
    response = None
    conn = None
    try:
        conn = domain_connect(config, domain, Domain)
        do_request(conn, operation, addr, data, headers)
        response = conn.getresponse()
        return response, conn
    except socket.sslerror, msg:  # Network error
        if not silent:
            log.info("SSL error: %s", msg)
    except socket.error, msg:  # Network error
        if not silent:
            log.debug("Network error: %s", msg)