This commit is contained in:
@@ -60,6 +60,8 @@ addLoggingLevel("TRACE", logging.DEBUG - 5)
|
||||
|
||||
|
||||
class ColoredFormatter(logging.Formatter):
|
||||
sensetive = set() # TODO: chain formatters?
|
||||
|
||||
def __init__(self, fmt):
|
||||
super().__init__()
|
||||
self.fmt = fmt
|
||||
@@ -72,7 +74,12 @@ class ColoredFormatter(logging.Formatter):
|
||||
logging.CRITICAL: colored(self.fmt, "red", attrs=["bold"]),
|
||||
}
|
||||
|
||||
def _mask_sensetive_data(self, message: str) -> str:
|
||||
for value in self.sensetive:
|
||||
message = message.replace(value, "*****")
|
||||
return message
|
||||
|
||||
def format(self, record: logging.LogRecord):
|
||||
log_fmt = self.FORMATS.get(record.levelno)
|
||||
formatter = logging.Formatter(log_fmt)
|
||||
return formatter.format(record)
|
||||
return self._mask_sensetive_data(formatter.format(record))
|
||||
|
||||
Reference in New Issue
Block a user