The raygun4py provider

This module is the official Raygun provider for Python 2.6/2.7 and Python 3+ apps. It allows you to automatically send and track all errors that occur in your Python code.

It features the ability to manually set up the error sending when one occurs, by creating a handler and attaching it to sys.excepthook, or automatically by adding the built-in logger.

Why add Raygun error tracking

Python's a great language for all sorts of environments. Scripting, web development, desktop apps and more can be crafted quickly and without hassle. If you're deploying code onto a system where you won't be staring at the output on your monitor all the time, knowing how the code is performing is critical. When your end users encounter an error, you should know about it instantly - or, if your web application falls over, having an email alert delivered to your inbox with the stack trace would surely speed up fixing the cause of the error!

Raygun provides all of this, and more.

Requirements

Raygun4py is known to work with Python 2.6-2.7 and Python 3.1-3.4 environments.

It requires the socket module to be build with SSL support.

Installation

It is available as a PyPI package, so it only takes a second to add it to your project:

pip install raygun4py

Usage

To automatically pick up unhandled exceptions with custom logic, you can provide a callback function to sys.excepthook:

from raygun4py import raygunprovider

def handle_exception(exc_type, exc_value, exc_traceback):
    sender = raygunprovider.RaygunSender("your_apikey")
    sender.send_exception(exc_info=(exc_type, exc_value, exc_traceback))

sys.excepthook = handle_exception

More usage scenarios are available in the full documentation.

Documentation

View the complete Raygun4py documentation here, including version and user tracking, global/local variable support, Django, Flask and WSGI middleware, HTTP request data and much more.

Raygun4py GitHub Repository

Visit the raygun4py GitHub repository to view the code. Like all our providers, it is available under the MIT license.