Skip to main content

Stackify API for Python

Project description

Stackify API for Python

Installation

stackify-python can be installed through pip:

$ pip install -U stackify-api-python

stackify-python-api can be installed through pip:

$ pip install stackify-api-python

Configuration

Standard API

import stackify
logger = stackify.getLogger(application="Python Application", environment="Production", api_key="***")
logger.warning('Something happened')

Python Logging Integration

import logging
import stackify
logger = logging.getLogger(__name__)
stackify_handler = stackify.StackifyHandler(application="Python Application", environment="Production", api_key="***")
logger.addHandler(stackify_handler)
logger.warning('Something happened')

Environment Settings

export STACKIFY_APPLICATION=Python Application
export STACKIFY_ENVIRONMENT=Production
export STACKIFY_API_KEY=******

Usage

stackify-python-api 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:

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
logger = logging.getLogger('stackify')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.FileHandler('stackify.log'))  # or any handler you want

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)

Django Logging Integration

You can also use your existing django logging and just append stackify logging handler

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': 'debug.log',
        },
        'stackify': {
            'level': 'DEBUG',
            'class': 'stackify.StackifyHandler',
            'application': 'MyApp',
            'environment': 'Dev',
            'api_key': '******',
        }
    },
    'loggers': {
        'django': {
            'handlers': ['file', 'stackify'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

Usage

import logging

logger = logging.getLogger('django')


logger.warning('Something happened')

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

stackify-api-python-1.0.4.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackify_api_python-1.0.4-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file stackify-api-python-1.0.4.tar.gz.

File metadata

  • Download URL: stackify-api-python-1.0.4.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for stackify-api-python-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f654747839484908eaac6ae98fc336cdb0004971c0bb535d9cf0d8a6935d6b38
MD5 888c17eb4ae3fdee3a8fcbcbc0e534c2
BLAKE2b-256 6fbcdddac6fc6d51beabee37c8e09a9174ac1e8b9a70caf4b31ce90ff52e22c2

See more details on using hashes here.

File details

Details for the file stackify_api_python-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: stackify_api_python-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for stackify_api_python-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5fe8703e9d768976461ec7db5728165cdf2b151061de7d8cb98c21d912bd416e
MD5 dd1c1256d5310175ff99b147b60cbcca
BLAKE2b-256 199fae209ef8a441aacf791903879207b1a2c74725b392605bc3a7dafd9c8bad

See more details on using hashes here.

Supported by

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