Skip to main content

Nice colorful formatters for Python logging.

Project description Latest PyPI version Number of PyPI downloads Supported Python versions Development Status License

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.


pip install nicelog

Example usage

import logging
import sys

from nicelog.formatters import Colorful

# Setup a logger
logger = logging.getLogger('foo')

# Setup a handler, writing colorful output
# to the console
handler = logging.StreamHandler(sys.stderr)

# Now log some messages..
logger.debug('Debug message')'Info message')
logger.warning('Warning message')
logger.error('Error message')
logger.critical('Critical message')
    raise ValueError('This is an exception')
    logger.exception("An error occurred")

Example output

Here it is, in all its glory:


The output format can be further customized, eg. if you want to reduce colorfulness or verbosity.



I usually put something like this in my (local) settings:

LOGGING['formatters']['standard'] = {
    '()': 'nicelog.formatters.ColorLineFormatter',
    'show_date': True,
    'show_function': True,
    'show_filename': True,
    'message_inline': False,



  • Replaced strftime(3) conversion specifiers %F and %T aren’t available on all platforms: replaced with long versions %Y-%m-%d and %H:%M:%S.


  • Prevent failure in case the TERM environment variable is not set (PR #1)


  • 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)


  • Added support for showing more information:
    • record date
    • file name / line number
    • module / function


  • 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.

Files for nicelog, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size nicelog-0.2-py2-none-any.whl (11.2 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size nicelog-0.2-py3-none-any.whl (11.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nicelog-0.2.tar.gz (8.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page