MCPcopy Create free account
hub / github.com/ForgeRock/forgeops / ColorFormatter

Class ColorFormatter

lib/python/utils.py:108–122  ·  view source on GitHub ↗

Logging color

Source from the content-addressed store, hash-verified

106 return formatter.format(record)
107
108class ColorFormatter(logging.Formatter):
109 """Logging color"""
110 TTY_FORMATS = {
111 logging.DEBUG: f'{BLUE}{MSG_FMT}{ENDC}',
112 logging.INFO: f'{CYAN}{MSG_FMT}{ENDC}',
113 logging.WARNING: f'{PURPLE}{MSG_FMT}{ENDC}',
114 logging.ERROR: f'{RED}{MSG_FMT}{ENDC}',
115 logging.CRITICAL: f'{RED}{MSG_FMT}{ENDC}',
116 }
117
118 def format(self, record):
119 log_fmt = self.TTY_FORMATS.get(record.levelno)
120 formatter = logging.Formatter(log_fmt)
121 formatter.datefmt = '%Y-%m-%dT%H:%M:%S%z'
122 return formatter.format(record)
123
124def logger(name=log_name, level=logging.INFO):
125 log = logging.getLogger(name)

Callers 1

loggerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected