This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A handler for the python logging module that sends logs through any REST-ful API. With threading and Loggly support that handles batch POSTS.

Project Description
# Python RESTful API Asyncronous Logging Handler with Loggly Support
A simple logging handler for python that will send any logging events out to a
RESTful API using HTTP POST requests. Fully asyncronuous using requests-futures,
tested for Python 2 & 3, and has support for Loggly.

## Installation
pip install restapi-logging-handler

## Usage
Import whichever module(s) you need:
```
from restapi_logging_handler import RestApiHandler
from restapi_logging_handler import LogglyHandler
```

### RESTful API Usage
Set your Python logging handler to send logs to a REST-ful API
```
logger = logging.getLogger(__name__)
restapiHandler = RestApiHandler('http://my.restfulapi.com/endpoint/')
logger.addHandler(restapiHandler)
logger.setLevel(logging.INFO)
logger.info("Send this to my RESTful API")
```

By default, it sends the log data as a JSON object. You can currently change
that to send text instead.
```
restapiHandler = RestApiHandler('http://my.restfulapi.com/endpoint/', 'text')
```

### Loggly Usage
Set your Python logging handler to send logs out to your Loggly account. The
handler collects logs in a batch and sends them out every `interval` seconds.
After the interval passes, Loggly is sent all the logs collected. There are
`max_attempts` attempts to send the logs before the internal handleError() method
and an exception are thrown.
####Parameters
- custom_token: The LogglyHandler takes as its first argument the custom token given to you
when you sign up for a Loggly account.
- app_tags: The second argument can be a tag string,
or a list of tags to be associated with the log inside of Loggly.
- interval: defaults to 1 second
- max_attempts: defaults to 5 attempts

```
logglyHandler = LogglyHandler(
custom_token='loggly-custom-key',
app_tags=['tag1','tag2',...],
interval=1.0,
max_attemps=5
)
```


## Testing
Install tox and run it to test against Python 2 and 3.
```
sudo pip install nose
tox
```

## Forking
If you'd like to extend this to include more REST-ful API's than just Loggly,
send me a pull request!
Release History

Release History

This version
History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.11

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.2

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
restapi-logging-handler-0.2.2.tar.gz (4.3 kB) Copy SHA256 Checksum SHA256 Source Feb 12, 2015

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