Added log.timestamp.

This commit is contained in:
Jeremy Fincher 2004-01-19 20:22:06 +00:00
parent 6950f65c98
commit dc87ed26aa
4 changed files with 12 additions and 9 deletions

View File

@ -73,11 +73,9 @@ class AsyncoreDriver(asynchat.async_chat, object):
self.close() self.close()
def scheduleReconnect(self): def scheduleReconnect(self):
when = time.time() + 60 when = log.timestamp(time.time()+60)
whenS = time.strftime(conf.supybot.log.timestampFormat(),
time.localtime(when))
if not world.dying: if not world.dying:
log.info('Scheduling reconnect to %s at %s', self.server, whenS) log.info('Scheduling reconnect to %s at %s', self.server, when)
def makeNewDriver(): def makeNewDriver():
self.irc.reset() self.irc.reset()
driver = self.__class__(self.server, self.irc) driver = self.__class__(self.server, self.irc)

View File

@ -35,6 +35,7 @@ import fix
import os import os
import sys import sys
import time
import cgitb import cgitb
import types import types
import atexit import atexit
@ -228,6 +229,12 @@ def getPluginLogger(name):
log.addHandler(handler) log.addHandler(handler)
return log return log
def timestamp(when=None):
if when is None:
when = time.time()
format = conf.supybot.log.timestampFormat()
return time.strftime(format, time.localtime(when))
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -152,10 +152,9 @@ class SocketDriver(drivers.IrcDriver):
def _scheduleReconnect(self): def _scheduleReconnect(self):
when = time.time() + self.reconnectWaits[self.reconnectWaitsIndex] when = time.time() + self.reconnectWaits[self.reconnectWaitsIndex]
whenS = time.strftime(conf.supybot.log.timestampFormat(), when = log.timestamp(when)
time.localtime(when))
if not world.dying: if not world.dying:
log.info('Scheduling reconnect to %s at %s', self.server, whenS) log.info('Scheduling reconnect to %s at %s', self.server, when)
schedule.addEvent(self.reconnect, when) schedule.addEvent(self.reconnect, when)
def name(self): def name(self):

View File

@ -92,8 +92,7 @@ def upkeep():
log.debug('Pattern cache size: %s'%len(ircutils._patternCache)) log.debug('Pattern cache size: %s'%len(ircutils._patternCache))
log.debug('HostmaskPatternEqual cache size: %s' % log.debug('HostmaskPatternEqual cache size: %s' %
len(ircutils._hostmaskPatternEqualCache)) len(ircutils._hostmaskPatternEqualCache))
log.info('%s upkeep ran.', log.info('%s upkeep ran.', log.timestamp())
time.strftime(conf.supybot.log.timestampFormat()))
return collected return collected
def makeDriversDie(): def makeDriversDie():