Skip to main content

Ultimate Python colorized logger with user-custom color

Project description Latest PyPI version

Ultimate Python colorized logger.

<nav class="contents local" id="contents" role="doc-toc"> </nav>


Generic usage example

This script runs like above screenshot.

import sys
import logging
from rainbow_logging_handler import RainbowLoggingHandler

def main_func():
    # setup `logging` module
    logger = logging.getLogger('test_logging')
    formatter = logging.Formatter("[%(asctime)s] %(name)s %(funcName)s():%(lineno)d\t%(message)s")  # same as default

    # setup `RainbowLoggingHandler`
    handler = RainbowLoggingHandler(sys.stderr, color_funcName=('black', 'yellow', True))

    logger.debug("debug msg")"info msg")
    logger.warn("warn msg")
    logger.error("error msg")
    logger.critical("critical msg")

        raise RuntimeError("Opa!")
    except Exception as e:

if __name__ == '__main__':

Usage with Django

Django is a popular Python web framework.

Put the following to your to get more pleasant development server console output:

# Add this to your
    # Install rainbow logging handler when running Django in develoment mode
    import sys
    LOGGING["handlers"]["rainbow"] = {"level": "DEBUG", "class": "rainbow_logging_handler.RainbowLoggingHandler", 'stream': sys.stderr}

More about configuring loggers for Django.


Column-by-column colored log

As apparent from above screenshot, each column of logs are differently colored. Even default coloring should make log reading easier.

User custom color

Every column colors are customizable.

formatter = logging.Formatter('%(pathname)s [%(module)s] - %(funcName)s:L%(lineno)d : %(message)s')
handler   = RainbowLoggingHandler(
    # Customizing each column's color
    color_pathname=('black', 'red'  , True), color_module=('yellow', None, False),
    color_funcName=('blue' , 'white', True), color_lineno=('green' , None, False),
logger.addHandler(handler)"hello custom world")

Above code produces output like this.

High portability

Linux, BSD, Mac OS, and Windows are supposed to be supported.

Runs with both Python 2.6 or higher & Python 3.2 or higher.


Install from PyPI

$ pip install rainbow_logging_handler

Install from Github repo

$ git clone
$ cd rainbow_logging_handler
$ ./ install


Mikko Ohtamaa <>, Sho Nakatani <>

And special thanks to 10sr for advice.


This is free and unencumbered public domain software. For more information, see <> or the accompanying LICENSE.txt file.

Download files

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

Source Distribution (15.1 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