From 8640a431608e2bce764be4766c88e951596374c1 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Tue, 9 Jul 2013 13:35:24 -0700 Subject: [PATCH] fixed bug in custom logger where calling super() on old-style class throws exception. --- packages/wakatime/log.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/wakatime/log.py b/packages/wakatime/log.py index 27adbc2..4e108bf 100644 --- a/packages/wakatime/log.py +++ b/packages/wakatime/log.py @@ -27,15 +27,13 @@ class CustomEncoder(json.JSONEncoder): class JsonFormatter(logging.Formatter): - def __init__(self, timestamp, endtime, isWrite, targetFile, version, - plugin, datefmt=None): + def setup(self, timestamp, endtime, isWrite, targetFile, version, plugin): self.timestamp = timestamp self.endtime = endtime self.isWrite = isWrite self.targetFile = targetFile self.version = version self.plugin = plugin - super(JsonFormatter, self).__init__(datefmt=datefmt) def format(self, record): data = OrderedDict([ @@ -66,14 +64,14 @@ def setup_logging(args, version): if not logfile: logfile = '~/.wakatime.log' handler = logging.FileHandler(os.path.expanduser(logfile)) - formatter = JsonFormatter( + formatter = JsonFormatter(datefmt='%Y-%m-%dT%H:%M:%SZ') + formatter.setup( timestamp=args.timestamp, endtime=args.endtime, isWrite=args.isWrite, targetFile=args.targetFile, version=version, plugin=args.plugin, - datefmt='%Y-%m-%dT%H:%M:%SZ', ) handler.setFormatter(formatter) logger = logging.getLogger()