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