fixed bug in custom logger where calling super() on old-style class throws exception.

This commit is contained in:
Alan Hamlett 2013-07-09 13:34:39 -07:00
parent ebf6a26321
commit e8e2b8368f
1 changed files with 3 additions and 5 deletions

View File

@ -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()