×


Using Python
We don't currently have a custom package available, however you can use our generic api at https://relay.errlog.io/api/v1/log to provide your own logging mechanism to your ErrLog.IO account.
For a look at the fields you can include with your API calls check out Payload Variables
Usage
Imports
Ensure you include the following imports directives in your code before using ErrLog.IO.
import json
import requests
from datetime import datetime
Craft your Payload
You can control what data goes into the package. This is probably best done as part of a try ... except ... block where you can pull values out of an Exception object.
You can see a full list of available fields here.
obj = {
    'message' : 'This is a test message from Python!!',
    'apikey' : '[Your-api-key]',
    'applicationname' : 'Python Test Application',
    'type' : 'SnakeException',
    'errordate' : datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"),
    'filename' : 'ErrLogSamplePython.py',
    'method' : 'Constructor',
    'lineno' : 12,
    'colno' : 34
}
Specify the end-point and headers
Here the URL needs to be defined as below and the Content-Type needs to be application/json.
Otherwise you will receive a 415 Unsupported Media Type response.
url = 'https://relay.errlog.io/api/v1/log'

headers = {'Content-Type': 'application/json','Accept': 'application/json'}
Preform the Request
After successfully loggin an error, you will receive an HTTP 200 response from the web request and your exception will have been logged to your ErrLog.IO dashboard.
r = requests.post(url, data = json.dumps(obj), headers = headers)

print "Response:", r
print "Text: " , r.text
Complete Code Sample
import json
import requests
from datetime import datetime

obj = {
    'message' : 'This is a test message from Python!!',
    'apikey' : '[Your-api-key]',
    'applicationname' : 'Python Test Application',
    'type' : 'SnakeException',
    'errordate' : datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"),
    'filename' : 'ErrLogSamplePython.py',
    'method' : 'Constructor',
    'lineno' : 12,
    'colno' : 34
}

url = 'https://relay.errlog.io/api/v1/log'
data = json.dumps(obj)

# If you want to see the data you're sending.
# print "Json Data: ", data


headers = {'Content-Type': 'application/json','Accept': 'application/json'}
r = requests.post(url, data = data, headers = headers)

print "Response:", r
print "Text: " , r.text