Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

spectrum-python is a Python Logging Handler for Spectrum (

Project Description


Spectrum is a application that helps developers filter and sift through logs while developing or debugging locally. It accepts logging information via a REST API, syslog, or can be set to tail local files. All of these logging sources are then easily shown or hidden depending on the current needs of the developer.

This Python package makes it trivially easy to push logs from Python and/or Django into Spectrum.


Installing Python support for Spectrum is as easy as:

$ pip install spectrum-python

Setting up a logging handler is also equally easy:

import logging
from spectrum.handlers import Spectrum

logger = logging.getLogger(__name__)

spectrum = Spectrum('my-logging-sublevel')

for i in range(5):"This would be sent as")
    logger.warn("This would be sent as")
    logger.debug("This would be sent as")



IP and PORT of the REST API to use. Defaults to ‘’. You must override this to the proper Spectrum port associated to your stream if using more than one REST API Stream


Optional sub-level to use for this handler. Defaults to ‘<untitled>’ in the Spectrum UI if not given.


To direct all logging from your Django project to Spectrum, you can use the predefined FIRE_HOSE logging configuration in your settings:


from spectrum.django import FIRE_HOSE

If you use celery, you’ll have one more setting to add:


You can also use the fire_hose convenience method to quickly modify any of the pre-built logging configuration dict:

from spectrum.django import fire_hose

LOGGING = fire_hose()

LOGGING = fire_hose(log_db=False)

LOGGING = fire_hose(levels=(
    ('my.overly.verbose.module', 'WARNING'),
    ('some.other.module', 'CRITICAL'),

LOGGING = fire_hose(handler_kwargs={'url': ''})

If you prefer a more granular approach, you can configure specific handlers:


    'filters': {
        'request_id': {
            '()': 'spectrum.filters.RequestIdFilter'
    'handlers': {
        'myloggername': {
            'level': 'DEBUG',
            'class': 'spectrum.handlers.RestSpectrum',
            'sublevel': 'myloggername',
            'filters': ['request_id']

Make sure you include the request_id filter to filter out spectrum’s own requests from the other. Otherwise, Spectrum’s requests will be logged by Python, and those logs will in turn generate their own Spectrum request, causing and infinite recursion.

Release History

This version
History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(7.5 kB) Copy SHA256 Hash SHA256
Source None Apr 24, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting