Python

Sample

An example Python project configured with BugSplat exception reporting can be found here.

Installation

BugSplat recommends you use bugsplat-py with a Python virtual environment. To create a virtual environment for your project please run the following command at your project's root directory:

python -m venv venv

Activate your virtual environment by running the following command:

# unix/macos
source venv/bin/activate

# windows
.\env\Scripts\activate

Install the bugsplat package using pip:

pip install bugsplat

Usage

Import the BugSplat class

from bugsplat import BugSplat

Create a new BugSplat instance passing it the name of your BugSplat database, application, and version

bugsplat = BugSplat(database, application, version)

Optionally, you set default values for key, description, email, user, and additionaFilePaths

bugsplat.set_default_app_key('key!')
bugsplat.set_default_description('description!')
bugsplat.set_default_email('fred@bugsplat.com')
bugsplat.set_default_user('Fred')
bugsplat.set_default_additional_file_paths([
    './path/to/additional-file.txt',
    './path/to/additional-file-2.txt'
])

Wrap your application code in a try/except block. In the except block call post. You can override any of the default properties that were set in step 3

try:
    crash()
except Exception as e:
    bugsplat.post(
        e,
        additional_file_paths=[],
        app_key='other key!',
        description='other description!',
        email='barney@bugsplat.com',
        user='Barney'
    )

Once you've posted a crash, navigate to the Crashes page and click the link in the ID column to see the crash's details

Thanks for using BugSplat ❤️

Last updated