kedro.extras.logging.color_logger.ColorHandler

class kedro.extras.logging.color_logger.ColorHandler(stream=None, colors=None)[source]

A color log handler.

You can use this handler by incorporating the example below into your logging configuration:

conf/project/logging.yml:

formatters:
  simple:
    format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

handlers:
  console:
    class: kedro.extras.logging.ColorHandler
    level: INFO
    formatter: simple
    stream: ext://sys.stdout
    # defining colors is optional
    colors:
      debug: white
      info: magenta
      warning: yellow

root:
  level: INFO
  handlers: [console]

The colors parameter is optional, and you can use any ANSI color.

  • Black

  • Red

  • Green

  • Yellow

  • Blue

  • Magenta

  • Cyan

  • White

The default colors are:

  • debug: magenta

  • info: cyan

  • warning: yellow

  • error: red

  • critical: red