Added command timing to the verbose log.

This commit is contained in:
Jeremy Fincher 2003-04-07 15:23:12 +00:00
parent 58902cd8fd
commit 89fa7855da

View File

@ -250,7 +250,10 @@ class IrcObjectProxy:
(self.msg.nick, name)) (self.msg.nick, name))
return return
command = getattr(callback, name) command = getattr(callback, name)
start = time.time()
callback.callCommand(command, self, self.msg, self.args) callback.callCommand(command, self, self.msg, self.args)
elapsed = time.time() - start
debug.msg('%s took %s seconds.' % (name, elapsed), 'verbose')
else: else:
self.args.insert(0, name) self.args.insert(0, name)
self.reply(self.msg, '[%s]' % ' '.join(self.args)) self.reply(self.msg, '[%s]' % ' '.join(self.args))
@ -293,8 +296,9 @@ class IrcObjectProxy:
class CommandThread(threading.Thread): class CommandThread(threading.Thread):
def __init__(self, command, irc, msg, args): def __init__(self, command, irc, msg, args):
name = '%s.%s with args %r' % (command.im_class.__name__, self.commandName = command.im_func.func_name
command.im_func.func_name, args) self.className = command.im_class.__name__
name = '%s.%s with args %r' % (self.className, self.commandName, args)
threading.Thread.__init__(self, target=command, name=name, threading.Thread.__init__(self, target=command, name=name,
args=(irc, msg, args)) args=(irc, msg, args))
self.irc = irc self.irc = irc
@ -303,7 +307,11 @@ class CommandThread(threading.Thread):
def run(self): def run(self):
try: try:
start = time.time()
threading.Thread.run(self) threading.Thread.run(self)
elapsed = time.time() - start
debug.msg('%s took %s seconds.' % \
(self.commandName, elapsed), 'verbose')
except Error, e: except Error, e:
self.irc.reply(self.msg, debug.exnToString(e)) self.irc.reply(self.msg, debug.exnToString(e))
except Exception, e: except Exception, e: