mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
Updated timestampFormat to handle the empty string.
This commit is contained in:
parent
7bf8ba2c35
commit
7fa9f47058
@ -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
|
* Added supybot.plugins.Weather.convert, which determines whether
|
||||||
or not Weather.{weather,cnn,ham} will convert temperature to the
|
or not Weather.{weather,cnn,ham} will convert temperature to the
|
||||||
configured temperatureUnit.
|
configured temperatureUnit.
|
||||||
|
14
src/log.py
14
src/log.py
@ -49,9 +49,7 @@ deadlyExceptions = [KeyboardInterrupt, SystemExit]
|
|||||||
|
|
||||||
class Formatter(logging.Formatter):
|
class Formatter(logging.Formatter):
|
||||||
def formatTime(self, record, datefmt=None):
|
def formatTime(self, record, datefmt=None):
|
||||||
if datefmt is None:
|
return timestamp(record.created)
|
||||||
datefmt = conf.supybot.log.timestampFormat()
|
|
||||||
return logging.Formatter.formatTime(self, record, datefmt)
|
|
||||||
|
|
||||||
def formatException(self, (E, e, tb)):
|
def formatException(self, (E, e, tb)):
|
||||||
for exn in deadlyExceptions:
|
for exn in deadlyExceptions:
|
||||||
@ -174,7 +172,11 @@ def timestamp(when=None):
|
|||||||
if when is None:
|
if when is None:
|
||||||
when = time.time()
|
when = time.time()
|
||||||
format = conf.supybot.log.timestampFormat()
|
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 firewall(f, errorHandler=None):
|
||||||
def logException(self, s=None):
|
def logException(self, s=None):
|
||||||
@ -255,7 +257,9 @@ stdout (if enabled) will be colorized with ANSI color."""))
|
|||||||
conf.supybot.log.register('timestampFormat',
|
conf.supybot.log.register('timestampFormat',
|
||||||
registry.String('[%d-%b-%Y %H:%M:%S]',
|
registry.String('[%d-%b-%Y %H:%M:%S]',
|
||||||
"""Determines the format string for timestamps in logfiles. Refer to the
|
"""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()):
|
if not os.path.exists(conf.supybot.directories.log()):
|
||||||
os.mkdir(conf.supybot.directories.log(), 0755)
|
os.mkdir(conf.supybot.directories.log(), 0755)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user