From 143f6ff0e2fee3c0d7cfea496c7379a4d48756d4 Mon Sep 17 00:00:00 2001 From: jcao219 Date: Tue, 16 Aug 2011 01:31:24 -0500 Subject: [PATCH] add timestamps for logging --- wolfbot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wolfbot.py b/wolfbot.py index 815ff2d..376517c 100644 --- a/wolfbot.py +++ b/wolfbot.py @@ -24,8 +24,12 @@ from oyoyo.parse import parse_nick import logging import botconfig import wolfgame +import time import traceback +class UTCFormatter(logging.Formatter): + converter = time.gmtime + def on_privmsg(cli, rawnick, chan, msg): if chan != botconfig.NICK: #not a PM if "" in wolfgame.COMMANDS.keys(): @@ -93,6 +97,9 @@ def __unhandled__(cli, prefix, cmd, *args): def main(): if not botconfig.DEBUG_MODE: 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: logging.basicConfig(level=logging.DEBUG)