Skip to content

logger

DGM_LEVEL = 15 module-attribute

ColoredFormatter

Bases: Formatter

COLORS = {'DEBUG': Fore.BLUE + Style.BRIGHT, 'DGM': Fore.CYAN + Style.BRIGHT, 'INFO': Fore.GREEN + Style.BRIGHT, 'WARNING': Fore.YELLOW, 'ERROR': Fore.RED + Style.BRIGHT, 'CRITICAL': Fore.MAGENTA + Style.BRIGHT} class-attribute instance-attribute

style = style instance-attribute

__init__(style=0)

format(record)

set_style(style)

Logger

Generic Logger class for logging to file and console in color.

Logging levels are

10 DEBUG 15 DGM 20 INFO 30 WARNING 40 ERROR 50 CRITICAL

get_level() staticmethod

Retrieve the current logging level.

Returns:

Type Description
str

The current logging level.

init(level=logging.INFO, to_file=False, style=0) staticmethod

Initialize the logger with optional parameters level and to_file.

Parameters:

Name Type Description Default
level LEVEL

Logging level. Defaults to INFO.

INFO
to_file bool

Write logs to file debug. Defaults to False.

False
style int

Output message styling. Defaults to 0.

0

set_level(level) staticmethod

Set the logging level.

Parameters:

Name Type Description Default
level LEVEL

Set logging level to this.

required

set_style(style) staticmethod

Set message style.

Parameters:

Name Type Description Default
style int

Log message style.

required

dgm(msg)

Custom DGM logging level.

timer(fn)

Time functions with decorator.