Coder Social home page Coder Social logo

stackify-api-python's Introduction

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')

stackify-api-python's People

Contributors

darinhoward avatar eric-martin avatar jaygel179 avatar mathom avatar

Watchers

 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.