| 34 | |
| 35 | @staticmethod |
| 36 | def _process(msg, loglevel, colorize): |
| 37 | loglevel = str(loglevel).lower() |
| 38 | if loglevel not in LOG_LEVELS: |
| 39 | raise RuntimeError(f"{loglevel} should be one of {LOG_LEVELS}." |
| 40 | ) # pragma: no cover |
| 41 | |
| 42 | msg = f"{str(loglevel).upper()}: {str(msg)}" |
| 43 | |
| 44 | if not colorize: |
| 45 | return msg |
| 46 | |
| 47 | if loglevel == DEBUG: |
| 48 | return "{}{}{}".format(fg(5), msg, attr(0)) # noqa: E501 |
| 49 | if loglevel == INFO: |
| 50 | return "{}{}{}".format(fg(4), msg, attr(0)) # noqa: E501 |
| 51 | if loglevel == WARNING: |
| 52 | return "{}{}{}{}{}".format(fg(214), attr(1), msg, attr(21), |
| 53 | attr(0)) # noqa: E501 |
| 54 | if loglevel == ERROR: |
| 55 | return "{}{}{}{}{}".format(fg(202), attr(1), msg, attr(21), |
| 56 | attr(0)) # noqa: E501 |
| 57 | if loglevel == CRITICAL: |
| 58 | return "{}{}{}{}{}".format(fg(196), attr(1), msg, attr(21), |
| 59 | attr(0)) # noqa: E501 |
| 60 | |
| 61 | def format(self, record): |
| 62 | record = copy(record) |