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()
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
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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for stackify-api-python-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ba64a13686031e750f841640cd4afd3134d59766358b4caf0de61db119451f |
|
MD5 | 1793ff7f6d970e64b97251b85095a7f7 |
|
BLAKE2b-256 | 63240d7be7dc584e5ac45849e7c4963a19cdc27d9b0ff3096ad40f85429019f5 |
Hashes for stackify_api_python-1.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb84bcb3d4ef7c76c154d26a9aadba69128e975e85d1ac65c7503f49b48da26 |
|
MD5 | 329f72c7b542168c6b353fe9b7f5f278 |
|
BLAKE2b-256 | bcb6f8a4dfeac0950372b68034aba453e4e99ad6710b71b715d0aa9e03d0469a |