Skip to main content

Simple wrapper for CLI script which can use all advantages of structlog

Project description

License: MIT Code style: black Python: 3.6

Simple wrapper for CLI script which can use all advantages of structlog and can work with modules which use old good standard lib logging as well

Q Why I need it?
A Write Logs for Machines, use JSON


By default script behave like a proper 12 factor app that outputs only JSON to stdout and leave the logs of libraries that use logging unchanged

python ./examples/

Wow, exception
Traceback (most recent call last):
  File "/home/mirror/PycharmProjects/structlog-boilerplate/examples/libs/", line 14, in f
    1 / 0
ZeroDivisionError: division by zero
{'event': 'Boom!!!!', 'logger': 'libs.structlog_lib', 'level': 'critical', 'timestamp': '2018-11-03T09:25:19.002335Z'}
{'event': 'Bang!', 'logger': 'libs.structlog_lib', 'level': 'error', 'timestamp': '2018-11-03T09:25:19.002424Z'}
{'event': 'Wow, exception', 'logger': 'libs.structlog_lib', 'level': 'error', 'timestamp': '2018-11-03T09:25:19.002550Z', 'exception': 'Traceback (most recent call last):\n  File "/home/mirror/PycharmProjects/structlog-boilerplate/examples/libs/", line 15, in f\n    1 / 0\nZeroDivisionError: division by zero'}
{"event": "result", "timestamp": "2018-11-03T09:25:19.002736Z", "value": 42}

But if verbosity level escalates, script produces developer friendly colored output

python ./examples/ -vv

colored output

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

structlog-boilerplate-0.2.tar.gz (3.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page