Skip to main content

spectrum-python is a Python Logging Handler for Spectrum (devspectrum.com)

Project description

Overview

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.

Python

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__)
logger.setLevel(logging.DEBUG)

spectrum = Spectrum('my-logging-sublevel')
logger.addHandler(spectrum)

for i in range(5):
    logger.info("This would be sent as INFO.my-logging-sublevel")
    logger.warn("This would be sent as WARNING.my-logging-sublevel")
    logger.debug("This would be sent as DEBUG.my-logging-sublevel")

Options

url

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

sublevel

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

Django

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

# settings.py

from spectrum.django import FIRE_HOSE
LOGGING = FIRE_HOSE

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

CELERYD_HIJACK_ROOT_LOGGER = False

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': '127.0.0.1:12345'})

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

spectrum-python-0.9.6.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file spectrum-python-0.9.6.tar.gz.

File metadata

File hashes

Hashes for spectrum-python-0.9.6.tar.gz
Algorithm Hash digest
SHA256 bb1ce2c24d3b387beda9c296c962859b78a29565b51619b9a387f5ea8e4e106d
MD5 9049e50ad08413aa6ad9545c677e33fb
BLAKE2b-256 d2d5cca69e74771ffabd979408b1ad3628660f2a479aef55751014a19c85fcca

See more details on using hashes here.

Supported by

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