Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

Stackify API for Python

Project Description

Stackify support for Python programs.

import stackify

logger = stackify.getLogger()

try:
    "Make it so, #" + 1
except:
    logger.exception("Can't add strings and numbers")

Installation

stackify-python can be installed through pip:

$ pip install -U stackify

You can also check out the repository and install with setuptools:

$ ./setup.py install

Configuration

Your Stackify setup information can be provided via environment variables. For example:

export STACKIFY_APPLICATION=MyApp
export STACKIFY_ENVIRONMENT=Dev
export STACKIFY_API_KEY=******

These options can also be provided in your code:

import stackify

logger = stackify.getLogger(application="MyApp", environment="Dev", api_key=******)
logger.warning('Something happened')

Usage

stackify-python handles uploads in batches of 100 messages at a time on another thread. When your program exits, it will shut the thread down and upload the remaining messages.

Stackify can store extra data along with your log message:

import stackify

logger = stackify.getLogger()

try:
    user_string = raw_input("Enter a number: ")
    print("You entered", int(user_string))
except ValueError:
    logger.exception('Bad input', extra={'user entered': user_string})

You can also name your logger instead of using the automatically generated one:

import stackify

logger = stackify.getLogger('mymodule.myfile')

Internal Logger

This library has an internal logger it uses for debugging and messaging. For example, if you want to enable debug messages:

import logging

logging.getLogger('stackify').setLevel(logging.DEBUG)

By default, it will enable the default logging settings via logging.basicConfig() and print WARNING level messages and above. If you wish to set everything up yourself, just pass basic_config=False in getLogger:

import stackify

logger = stackify.getLogger(basic_config=False)

Testing

Run the test suite with setuptools:

$ ./setup.py test

You can obtain a coverage report with nose:

$ ./setup nosetests --with-coverage --cover-package=stackify

You might need to install the nose and coverage packages.

Release History

Release History

This version
History Node

0.0.1

Supported By

WebFaction WebFaction Technical Writing 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 Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting