Add a custom Logger class with both verbose and trace levels. (#5613)

* rearrange commits

* Update redbot/setup.py

* change rich log level colours
This commit is contained in:
Draper
2022-03-15 20:20:37 +00:00
committed by GitHub
parent 7d716a2d67
commit 593eeb5362
6 changed files with 63 additions and 10 deletions

22
redbot/_log.py Normal file
View File

@@ -0,0 +1,22 @@
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)