Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python logging formatter that prefix multiline log message and trackebacks.

Project Description

Python logging formatter that prefix multiline log message and trackebacks. Makes the logs more readable, both for tracebacks and for multiline log messages.

  • Free software: BSD license

Benchmarking

Benchmark against pythons built in formatter logging.Formatter. The benchmark is done using pytest-benchmark, and the below results is from a run on a faily new MacBook Pro, using Python 2.7.

One should note that we are using StringIO as stream output, so we should expect the results to be even closer with more production alike setup, for example writing to disc.

Installation

pip install multiline-log-formatter

Usage

Add this to dictConfig:

'formatters': {
    'default': {
        '()': 'multiline_formatter.formatter.MultilineMessagesFormatter',
        'format': '[%(levelname)s] %(message)s'
    },
},

And log messages will look like this:

[ERROR] LOGGING_MESSAGE ... (49564:MainThread)
... (49564:MainThread) : Traceback (most recent call last):
... (49564:MainThread) :   File "/Users/plauri/work/opensource/python-multiline-log-formatter/tests/test_multiline_formatter.py", line 112, in test_exception
... (49564:MainThread) :     raise Exception('EXCEPTION_MESSAGE')
... (49564:MainThread) : Exception: EXCEPTION_MESSAGE

And if you don’t like the default, you can customize it by extending MultilineMessagesFormatter and set multiline_marker. You can also change multiline_fmt, but assure you include %(message)s in the formating string.

Development

To run the all tests run:

tox

Other

This project sceleton is generated by ionelmc’s pylibrary cookiecutter.

Changelog

0.1.8 (2016-01-15)

  • First release on PyPI.
Release History

Release History

This version
History Node

0.1.8

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
multiline_log_formatter-0.1.8-py2.py3-none-any.whl (5.5 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jan 15, 2016
multiline-log-formatter-0.1.8.tar.gz (306.6 kB) Copy SHA256 Checksum SHA256 Source Jan 15, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting