Browse Source

add timestamps for logging

master
jcao219 14 years ago
parent
commit
143f6ff0e2
  1. 7
      wolfbot.py

7
wolfbot.py

@ -24,8 +24,12 @@ from oyoyo.parse import parse_nick
import logging import logging
import botconfig import botconfig
import wolfgame import wolfgame
import time
import traceback import traceback
class UTCFormatter(logging.Formatter):
converter = time.gmtime
def on_privmsg(cli, rawnick, chan, msg): def on_privmsg(cli, rawnick, chan, msg):
if chan != botconfig.NICK: #not a PM if chan != botconfig.NICK: #not a PM
if "" in wolfgame.COMMANDS.keys(): if "" in wolfgame.COMMANDS.keys():
@ -93,6 +97,9 @@ def __unhandled__(cli, prefix, cmd, *args):
def main(): def main():
if not botconfig.DEBUG_MODE: if not botconfig.DEBUG_MODE:
logging.basicConfig(filename='errors.log', filemode='a', level=logging.WARNING) logging.basicConfig(filename='errors.log', filemode='a', level=logging.WARNING)
formatter = UTCFormatter('[%(asctime)s] %(message)s', '%d/%b/%Y %H:%M:%S')
for handler in logging.getLogger().handlers:
handler.setFormatter(formatter)
else: else:
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)

Loading…
Cancel
Save