Giter VIP home page Giter VIP logo

django-errorstack's Introduction

django-errorstack

A Django reusable application for logging errors to the ErrorStack service.

Installation

Install from PyPI with easy_install or pip:

pip install django-errorstack

or get the in-development version:

pip install django-errorstack==tip

Dependencies

django-errorstack requires Django 1.0 or later.

Usage

To use django-errorstack in your Django project:

  1. Add 'errorstack' to your INSTALLED_APPS setting.
  2. Set the ERRORSTACK_STACK_KEY setting.
  3. Add errorstack.middleware.ErrorStackMiddleware to the end of your MIDDLEWARE_CLASSES setting.

When DEBUG is False, all unhandled view exceptions will be logged to ErrorStack. Error handling will otherwise proceed as it would otherwise: django-errorstack does not disable or modify Django's usual error handling.

Logging errors manually

You may want to log some errors to ErrorStack in your own code, without raising an unhandled exception or displaying a 500 page to your user.

django-errorstack uses a named logger from the Python standard library logging module. The name of the logger is defined by the ERRORSTACK_LOGGER_NAME setting (defaults to "errorstack"). Assuming you don't change the setting, you could log errors yourself like this:

import logging

logger = logging.getLogger("errorstack")

try:
    #... some code that raises an exception
except:
    logger.error("Something bad happpened.", exc_info=True)

This logger only sends errors or critical errors (not warnings or info or debug messages) to ErrorStack.

Attaching the ErrorStack handler to your own logger

Your application may already use the stdlib logging module with your own named loggers. If you want to attach the ErrorStack logger handler to your own loggers, you can do the following:

import logging

from errorstack.handlers import errorstack_handler

logger = logging.getLogger("my_logger")
logger.addHandler(errorstack_handler)

Again, this handler only listens for errors or critical errors.

Settings

ERRORSTACK_STACK_KEY

The key of the error stack you want to send errors to. This option is required.

ERRORSTACK_CATCH_404

Log Http404 exceptions to ErrorStack if this is True. False by default.

ERRORSTACK_LOGGER_NAME

The logger name to use. Defaults to "errorstack".

django-errorstack's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.