Small handler and formatter for using python logging with Redis
Project description
Small handler and formatter for using python logging with Redis.
This is cleared and simplified version of
python-redis-log by Jed
Parsons, with Python3 support.
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.
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:
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.
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
rlog-0.1.tar.gz
(3.9 kB
view details)
File details
Details for the file rlog-0.1.tar.gz
.
File metadata
- Download URL: rlog-0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa8377cb3d06beb6dd7879ac6552f301203ef5d4beacc807812b909433a82b3 |
|
MD5 | ef8893adf9298bc91f3800b0bcf42cb9 |
|
BLAKE2b-256 | b988f91f9a106c662eabfaf07c453f63a3878e09fa93d59643400d2f47e67d81 |