feat(logging): mask sensetive data in log output
test / test (push) Successful in 2m0s

This commit is contained in:
2026-10-04 16:29:08 +03:00
parent b459eef34b
commit 549979ced6
5 changed files with 26 additions and 3 deletions
+8 -1
View File
@@ -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))