Using utils.stackTrace now that it has a compact option.

This commit is contained in:
Jeremy Fincher 2004-08-21 07:29:33 +00:00
parent 3bacc7d0b7
commit 247f8f4cc6

View File

@ -103,15 +103,11 @@ class IrcHandler(logging.Handler):
class IrcFormatter(log.Formatter):
def formatException(self, (E, e, tb)):
L = [utils.exnToString(e), '::']
while tb:
lineno = tb.tb_lineno
code = tb.tb_frame.f_code
function = code.co_name
filename = os.path.basename(code.co_filename)
L.append('[%s|%s|%s]' % (filename, function, lineno))
tb = tb.tb_next
frames = utils.stackTrace(frame=tb.tb_frame, compact=True).split()
frames.reverse()
L.extend(frames)
del tb
while sum(imap(len, L)) > 425:
while sum(imap(len, L)) > 350:
L.pop()
return ' '.join(L)
@ -119,9 +115,8 @@ class IrcFormatter(log.Formatter):
class ColorizedIrcFormatter(IrcFormatter):
def formatException(self, (E, e, tb)):
if conf.supybot.plugins.LogToIrc.colorized():
return ircutils.mircColor(IrcFormatter.formatException(self,
(E, e, tb)),
fg='red')
s = IrcFormatter.formatException(self, (E, e, tb))
return ircutils.mircColor(s, fg='red')
else:
return IrcFormatter.formatException(self, (E, e, tb))