Skip to content

Commit 08e10c5

Browse files
arHSMi0bs
andauthored
fix: improve custom formatter class (#585)
* docs: add migration docs for 4.1 * docs: detail message content intent in migration * ADMIN/chore: finish catchup from rebase (#573) * docs: add migration docs for 4.1 * docs: detail message content intent in migration * ADMIN/chore: finish catchup from rebase (#573) (#574) * docs: add migration docs for 4.1 * docs: detail message content intent in migration * fix: imporve custom formatter class Co-authored-by: fl0w <41456914+goverfl0w@users.noreply.github.com> Co-authored-by: James Walston <officialdeltadev@gmail.com>
1 parent 9f3e473 commit 08e10c5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

interactions/base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ def __init__(self):
6767
init(autoreset=True)
6868

6969
def format(self, record):
70-
log_format = self.formats.get(record.levelno)
71-
formatter = logging.Formatter(log_format)
72-
return formatter.format(record)
70+
# reference
71+
# https://github.com/python/cpython/blob/3.10/Lib/logging/__init__.py#L420
72+
# https://github.com/python/cpython/blob/3.10/Lib/logging/__init__.py#L665-L695
73+
74+
# set format for the style class
75+
self._style._fmt = self.formats.get(record.levelno)
76+
# call the default formatting fuction
77+
return logging.Formatter.format(self, record)

0 commit comments

Comments
 (0)