Draper 593eeb5362
Add a custom Logger class with both verbose and trace levels. (#5613)
* rearrange commits

* Update redbot/setup.py

* change rich log level colours
2022-03-15 16:20:37 -04:00

23 lines
641 B
Python

import logging as _logging
__ALL__ = ["VERBOSE", "TRACE", "RedTraceLogger"]
VERBOSE = _logging.DEBUG - 3
TRACE = _logging.DEBUG - 5
class RedTraceLogger(_logging.getLoggerClass()):
def __init__(self, name, level=_logging.NOTSET):
super().__init__(name, level)
_logging.addLevelName(VERBOSE, "VERBOSE")
_logging.addLevelName(TRACE, "TRACE")
def verbose(self, msg, *args, **kwargs):
if self.isEnabledFor(VERBOSE):
self._log(VERBOSE, msg, args, **kwargs)
def trace(self, msg, *args, **kwargs):
if self.isEnabledFor(TRACE):
self._log(TRACE, msg, args, **kwargs)