Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lobziik/rlog
Small handler and formatter for using python logging with Redis
https://github.com/lobziik/rlog
logging logs python redis
Last synced: 2 months ago
JSON representation
Small handler and formatter for using python logging with Redis
- Host: GitHub
- URL: https://github.com/lobziik/rlog
- Owner: lobziik
- Created: 2014-06-03T10:36:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-17T10:41:50.000Z (over 5 years ago)
- Last Synced: 2024-02-01T10:00:29.278Z (11 months ago)
- Topics: logging, logs, python, redis
- Language: Python
- Size: 33.2 KB
- Stars: 26
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
rlog
====Small handler and formatter for using python logging with Redis.
This is cleared and simplified version of [python-redis-log](https://github.com/jedp/python-redis-log
) by Jed Parsons, with Python3 support.[![Build Status](https://travis-ci.org/lobziik/rlog.svg?branch=master)](https://travis-ci.org/lobziik/rlog)
[![Coverage Status](https://coveralls.io/repos/lobziik/rlog/badge.png?branch=master)](https://coveralls.io/r/lobziik/rlog?branch=master)Installation
------------The current stable release:
pip install rlog
or:
easy_install rlog
or from source:$ sudo python setup.py install
Usage
----->>> from rlog import RedisHandler
>>> logger = logging.getLogger()
>>> logger.addHandler(RedisHandler(channel='test'))
>>> logger.warning("Spam!")
>>> logger.error("Eggs!")Redis clients subscribed to ``test`` will get a json log record by default.
_RedisHandler_ and _RedisListHandler_ also accepted all redis client settings as kwargs. More info about client settings
you may find in [redis-py](https://github.com/andymccurdy/redis-py) documentation.Custom formatters also supported, handlers accept this as _formatter_ keyword argument. JSONFormatter from this package
used as default.You can use the ``redis-cli`` shell that comes with ``redis`` to test this. At
the shell prompt, type ``subscribe my:channel`` (replacing with the channel
name you choose, of course). You will see subsequent log data printed in the
shell.Also you can use it with Django:
```Python
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'redis': {
'level': 'DEBUG',
'class': 'rlog.RedisHandler',
'host': 'localhost',
'password': 'redis_password',
'port': 6379,
'channel': 'my_amazing_logs'
}
},
'loggers': {
'django': {
'level': 'INFO',
'handlers': ['redis'],
'propagate': True,
},
}
}
```You can also simply use it with logstash.