Logging color
| 106 | return formatter.format(record) |
| 107 | |
| 108 | class 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 | |
| 124 | def logger(name=log_name, level=logging.INFO): |
| 125 | log = logging.getLogger(name) |