This commit is contained in:
Miroslav Stampar
2018-10-03 11:02:13 +02:00
parent 79e45bd8d7
commit 2e53096962
3 changed files with 7 additions and 5 deletions

View File

@@ -181,8 +181,10 @@ class ColorizingStreamHandler(logging.StreamHandler):
if level != "PAYLOAD":
if any(_ in message for _ in ("parsed DBMS error message",)):
string = re.search(r": '(.+)'", message).group(1)
message = message.replace("'%s'" % string, "'%s'" % ''.join((self.csi, str(self.color_map["white"] + 30), 'm', string, self._reset(message))), 1)
match = re.search(r": '(.+)'", message)
if match:
string = match.group(1)
message = message.replace("'%s'" % string, "'%s'" % ''.join((self.csi, str(self.color_map["white"] + 30), 'm', string, self._reset(message))), 1)
else:
for match in re.finditer(r"[^\w]'([^']+)'", message): # single-quoted
string = match.group(1)