A simple python logging formater to add ANSI color codes depending on log level for a prettier output in console.

Lertsenem da2fc7b3d6 Adding gitignore 7 years ago
.gitignore da2fc7b3d6 Adding gitignore 7 years ago
README.md 822ac3e7ff Adding README 7 years ago
__init__.py f2aff89801 Initial commit 7 years ago

README.md

pycolog

Simple logging formatter adding color codes to messages depending on log level. It's easy but I was tired of rewriting it on each project.

Use it like this:

from pycolog import ColoredFormatter

# You can use it as a regular formatter, specifying fmt as you need.
log_formatter = ColoredFormatter("%(asctime)s: %(message)s" 

# You also may chose a custom color set. Any level not specified will be
# printed with regular color.
log_formatter2 = ColoredFormatter( "%(message)s",
                                   colors = {
                                       "WARNING" : ColoredFormatter.BLUE,
                                       "ERROR"   : ColoredFormatter.YELLOW,
                                       } )

The code is really easy. Take a look if you want more details (all available colors and such).