Updated timestampFormat to handle the empty string.

This commit is contained in:
Jeremy Fincher 2004-04-14 02:37:17 +00:00
parent 7bf8ba2c35
commit 7fa9f47058
2 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,7 @@
* Changed supybot.log.timestampFormat to specially handle the
empty string -- if it's set to the empty string, it will log
times in seconds-since-epoch format.
* Added supybot.plugins.Weather.convert, which determines whether
or not Weather.{weather,cnn,ham} will convert temperature to the
configured temperatureUnit.

View File

@ -49,9 +49,7 @@ deadlyExceptions = [KeyboardInterrupt, SystemExit]
class Formatter(logging.Formatter):
def formatTime(self, record, datefmt=None):
if datefmt is None:
datefmt = conf.supybot.log.timestampFormat()
return logging.Formatter.formatTime(self, record, datefmt)
return timestamp(record.created)
def formatException(self, (E, e, tb)):
for exn in deadlyExceptions:
@ -174,7 +172,11 @@ def timestamp(when=None):
if when is None:
when = time.time()
format = conf.supybot.log.timestampFormat()
return time.strftime(format, time.localtime(when))
t = time.localtime(when)
if format:
return time.strftime(format, t)
else:
return str(int(time.mktime(t)))
def firewall(f, errorHandler=None):
def logException(self, s=None):
@ -255,7 +257,9 @@ stdout (if enabled) will be colorized with ANSI color."""))
conf.supybot.log.register('timestampFormat',
registry.String('[%d-%b-%Y %H:%M:%S]',
"""Determines the format string for timestamps in logfiles. Refer to the
Python documentation for the time module to see what formats are accepted."""))
Python documentation for the time module to see what formats are accepted.
If you set this variable to the empty string, times will be logged in a
simple seconds-since-epoch format."""))
if not os.path.exists(conf.supybot.directories.log()):
os.mkdir(conf.supybot.directories.log(), 0755)