class documentation

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
Method __init__ Undocumented
Method format The handler formatter.
Instance Variable colors Undocumented
Method _get_color Undocumented
def __init__(self, stream=None, colors=None): (source)

Undocumented

def format(self, record: logging.LogRecord) -> str: (source)

The handler formatter.

Parameters
record:logging.LogRecordThe record to format.
Returns
strThe record formatted as a string.

Undocumented

def _get_color(self, level): (source)

Undocumented