Skip to main content

Nice colorful formatters for Python logging.

Project description

https://travis-ci.org/rshk/nicelog.svg?branch=master https://coveralls.io/repos/rshk/nicelog/badge.png Latest PyPI version Number of PyPI downloads

Provide formatters to nicely display colorful logging output on the console.

Fork this project on GitHub

Right now, it contains only one formatter, coloring log lines depending on the log level and adding nice line prefixes containing logger name, but future plans are to add more formatters and allow better ways to customize them.

Example usage

from nicelog.formatters import ColorLineFormatter
import logging
import sys

logger = logging.getLogger('foo')
logger.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(ColorLineFormatter())
handler.setLevel(logging.DEBUG)

logger.addHandler(handler)

logger.debug('Debug message')
logger.info('Info message')
logger.warning('Warning message')
logger.error('Error message')
logger.critical('Critical message')

Example output

Here it is, in all its glory:

Screenshot

If you want to see what it looks like in 256color mode, with all the fields enabled:

Screenshot

Powerline font support

You can set the HAS_POWERLINE_FONT environment variable to a non-null value in order to tell the formatter to use powerline-style symbols (specifically, the “arrow” thing).

Changelog

v0.1.7

  • Added support for message_inline argument. If set to False, messages will be displayed on their own line (useful when enabling a lot of information)

v0.1.6

  • Added support for showing more information:

    • record date

    • file name / line number

    • module / function

v0.1.5

  • Added support for nicer colors in 256-color mode

  • Removed dependency from termcolor (now shipping better implementation)

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

nicelog-0.1.7.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file nicelog-0.1.7.tar.gz.

File metadata

  • Download URL: nicelog-0.1.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nicelog-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b65c5e82dc2f4d5139b6115a6d059b880e69afe03a9dc83ab846cf0ae15eaebf
MD5 65e95e31b3bf6fe2bb1eaf9b888b2af4
BLAKE2b-256 372e0fb5452438af33f48f2f1eb326520852db688586f283bb566183ea112dac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page