A collection of useful log formats for Python Loggers.
Project description
pyLogFormats
A collection of Logging Formats for the Pyton Standard Logger. Thats it.
Right now, this is a fairly small list, however there are a few log formats that I'd like to add. Checkout the Future Additions Section below.
Github-flavored Markdown to write your content.
Formats Included:
- BunyanFormat (https://github.com/trentm/node-bunyan)
- JSONFormat
- AdvJSONFormat (For Verbose JSON Logging)
Installation
Clone the git repo
git clone git@github.com:MattLimb/pylogformats.git
Install
python3 -m pip install pylogformats
Usage
Use the formatter as you would any other Python Formatter:
import pylogformat
import logging
import sys
logger = logging.getLogger()
logHandler = logging.StreamHandler(sys.stdout)
formatter = AdvJSONFormat()
logHandler.setFormatter(formatter)
logger.addHandler(logHandler)
logger.setLevel(logging.DEBUG)
You can also use dictConfig
:
LOG_CONFIG = {
'formatters': {
'jsonformatter': {
'()' : 'pylogformats.JSONFormat'
}
},
'handlers': {
'debug': {
'class': 'logging.StreamHandler',
'formatter': 'jsonformatter',
'stream': 'ext://sys.stdout'
},
},
'root': {
'level': 'DEBUG',
'handlers': ['debug']
},
'version': 1
}
import logging.config
logging.config.dictConfig(LOG_CONFIG)
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
pyLogFormats-0.0.1.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for pyLogFormats-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0a53b6bbe79f9f17fc05f69e60d9eb3a88f0c5c75939ac3ad396a3e073ff9a4 |
|
MD5 | ae83722a0060da63da6a2f98d64d1c80 |
|
BLAKE2b-256 | 3821748a6327d16af65f5c8748e94296b8bb379244263e150ee6ad19d5bff409 |