File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,27 @@ def format(self, record):
6060 record .isodate = date .isoformat ()
6161 record .message = record .msg % record .args
6262 record .coloredlevel = colorize (record .levelname , record .levelname )
63- return "%(isodate)s %(coloredlevel)s [process=%(processName)s, pid=%(process)s]: %(message)s" % record .__dict__
63+ s = "%(isodate)s %(coloredlevel)s [process=%(processName)s, pid=%(process)s]: %(message)s" % record .__dict__
64+
65+ # C&P from logging.Formatter#format
66+ if record .exc_info :
67+ # Cache the traceback text to avoid converting it multiple times
68+ # (it's constant anyway)
69+ if not record .exc_text :
70+ record .exc_text = self .formatException (record .exc_info )
71+ if record .exc_text :
72+ if s [- 1 :] != "\n " :
73+ s = s + "\n "
74+ try :
75+ s = s + record .exc_text
76+ except UnicodeError :
77+ # Sometimes filenames have non-ASCII chars, which can lead
78+ # to errors when s is Unicode and record.exc_text is str
79+ # See issue 8924.
80+ # We also use replace for when there are multiple
81+ # encodings, e.g. UTF-8 for the filesystem and latin-1
82+ # for a script. See issue 13232.
83+ s = s + record .exc_text .decode (sys .getfilesystemencoding (),
84+ 'replace' )
85+
86+ return s
You can’t perform that action at this time.
0 commit comments