Python errors Catcher module for Hawk.so.
Register an account and get a new project token.
If you want to connect specific frameworks see Flask integration, FastAPI integration.
Install hawkcatcher
from PyPI.
$ pip install hawkcatcher
Import Catcher module to your project.
from hawkcatcher import Hawk
Then enable Hawk Catcher with your token and domain.
hawk = Hawk(
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwcm9qZWN0SWQiOiI1ZTZmNWM3NzAzOWI0MDAwMjNmZDViODAiLCJpYXQiOjE1ODQzNTY0NzF9.t-5Gelx3MgHVBrxTsoMyPQAdQ6ufVbPsts9zZLW3gM8")
Now all global errors would be sent to Hawk.
If you want to catch errors in try-except blocks then use hawk.catch()
in except:
try:
...
except:
hawk.send()
You can also pass event to the hawk.send()
call, for example:
try:
...
except:
hawk.send(ValueError("error description"))
It is possible to pass additional event context for debugging purposes:
try:
...
except:
hawk.send(ValueError("error description"), {"params": "value"})
You can also pass user, who affected with specific error:
try:
...
except:
hawk.send(ValueError("error description"), {"params": "value"}, {"id": 123})
To init Hawk Catcher just pass a project token.
hawk = Hawk('1234567-abcd-8901-efgh-123456789012')
If you need to use custom Hawk server then pass a dictionary with params.
hawk = Hawk({
'token': '1234567-abcd-8901-efgh-123456789012',
'collector_endpoint': 'https://<id>.k1.hawk.so',
})
Parameters:
name | type | required | description |
---|---|---|---|
token |
str | required | Your project's Integration Token |
release |
str | optional | Release name for Suspected Commits feature |
collector_endpoint |
string | optional | Collector endpoint for sending event to |
context |
dict | optional | Additional context to be send with every event |
before_send |
Callable[[dict], None] | optional | This Method allows you to filter any data you don't want sending to Hawk |
- Python >= 3.9
- requests
Repository: https://github.com/codex-team/hawk.python
Report a bug: https://github.com/codex-team/hawk.python/issues
PyPI Package: https://pypi.python.org/pypi/hawkcatcher
CodeX Team: https://codex.so/