For structured logging.
Project description
log
Python library/client for structured log output
pip install spacemakerlog3
NB: As for now the log client for Python3 only supports logging JSON format.
Usage
from spacemakerlog3 import log
log.debug('hello something happened', some_key='with some value', another_key=123.12)
Output:
{"message": "hello something happened", "timestamp": "2018-08-05T18:08:01.780036Z", "another_key": 123.12, "level": "debug", "some_key": "with some value"}
Log exception with stacktrace:
from spacemakerlog3 import log
try:
raise Exception('some error message')
except Exception as e:
log.error('oooops, an error occured while doing something', exception=e)
Output:
{"message": "oooops, an error occured while doing something", "timestamp": "2018-08-15T08:49:46.707435Z", "level": "error", "exception": "Traceback (most recent call last):\n File \"/someProject/some-spacemaker-app/some_module.py\", line 76, in some_method\n raise Exception('some error message')\nException: some error message"}
Settings
The log client will read from environment variables at "init" for log level and format.
Env | default |
---|---|
LOG_FORMAT |
"json" |
LOG_LEVEL |
"debug" |
Set log format to "text":
log.set_format('text');
Set log level to "info":
log.set_level('info');
Publish
Using twine for publishing to PyPI.
brew install twine
python setup.py bdist_wheel
twine upload dist/*
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
spacemakerlog3-0.1.1.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for spacemakerlog3-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fde1d69cd4ce4e62ac7bd898dce93a3dbd8523f8da96d58c8584e21d5e8c3003 |
|
MD5 | 231f1b0bea3a25602bdc280220870336 |
|
BLAKE2b-256 | dab14c53e8a1c532a0dced1f228860b468d331e5da2c51ba8bd7c78a034f9179 |