mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 17:32:31 -05:00
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:
22
redbot/_log.py
Normal file
22
redbot/_log.py
Normal 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)
|
||||
Reference in New Issue
Block a user