Skip to main content

Python errors Catcher module for Hawk.

Project description

Hawk Python Catcher

Python errors Catcher module for Hawk.so.

Usage

Register an account and get a new project token.

If you want to connect specific frameworks see Flask integration, FastAPI integration.

Install module

Install hawk-python-sdk from PyPI.

$ pip install hawk-python-sdk

Import Catcher module to your project.

from hawk_python_sdk 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.

Try-except

If you want to catch errors in try-except blocks then use hawk.catch() in except:

try:
    ...
except:
    hawk.send()

Manual sending

You can also pass event to the hawk.send() call, for example:

try:
    ...
except:
    hawk.send(ValueError("error description"))

Event context

It is possible to pass additional event context for debugging purposes:

try:
    ...
except:
    hawk.send(ValueError("error description"), {"params": "value"})

Affected user

You can also pass user, who affected with specific error:

try:
    ...
except:
    hawk.send(ValueError("error description"), {"params": "value"}, {"id": 123})

Init params

To init Hawk Catcher just pass a project token.

hawk = Hawk('1234567-abcd-8901-efgh-123456789012')

Additional params

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

Requirements

  • Python >= 3.9
  • requests

Links

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/hawk-python-sdk

CodeX Team: https://codex.so/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hawk_python_sdk-3.5.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hawk_python_sdk-3.5.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file hawk_python_sdk-3.5.1.tar.gz.

File metadata

  • Download URL: hawk_python_sdk-3.5.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for hawk_python_sdk-3.5.1.tar.gz
Algorithm Hash digest
SHA256 21c46138ae6b3ca6c9f60f830a4b5e61448ed1936edab3b38b69a807559976c7
MD5 c3e102688e8d031b88db1ce862a697f1
BLAKE2b-256 a3fa611923e8d72196607db21ae25e651a2c472aa958115809214923af7a868b

See more details on using hashes here.

File details

Details for the file hawk_python_sdk-3.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hawk_python_sdk-3.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f66e485f16872fb74a4f3343f695c8a97d9fb410493eed3754e34fc3c791e0c1
MD5 c2a3fb88e2464a5ed9ac32d9d9538255
BLAKE2b-256 f7d65fed52efe277d88e24b9040d96598f3b93cd1f16361b94df7a793a6d7731

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page