@@ -0,0 +1,2873 @@
+# -*- coding: utf-8 -*-%0A%22%22%22%0A    wakatime.logger%0A    ~~~~~~~~~~~~~~~%0A%0A    Provides the configured logger for writing JSON to the log file.%0A%0A    :copyright: (c) 2013 Alan Hamlett.%0A    :license: BSD, see LICENSE for more details.%0A%22%22%22%0A%0Aimport logging%0Aimport os%0Aimport sys%0A%0Afrom .packages import simplejson as json%0Afrom .compat import u%0Atry:%0A    from collections import OrderedDict%0Aexcept ImportError:%0A    from .packages.ordereddict import OrderedDict%0A%0A%0Aclass CustomEncoder(json.JSONEncoder):%0A%0A    def default(self, obj):%0A        if isinstance(obj, bytes):%0A            obj = bytes.decode(obj)%0A            return json.dumps(obj)%0A        try:%0A            encoded = super(CustomEncoder, self).default(obj)%0A        except UnicodeDecodeError:%0A            obj = u(obj)%0A            encoded = super(CustomEncoder, self).default(obj)%0A        return encoded%0A%0A%0Aclass JsonFormatter(logging.Formatter):%0A%0A    def setup(self, timestamp, isWrite, targetFile, version, plugin):%0A        self.timestamp = timestamp%0A        self.isWrite = isWrite%0A        self.targetFile = targetFile%0A        self.version = version%0A        self.plugin = plugin%0A%0A    def format(self, record):%0A        data = OrderedDict(%5B%0A            ('now', self.formatTime(record, self.datefmt)),%0A            ('version', self.version),%0A            ('plugin', self.plugin),%0A            ('time', self.timestamp),%0A            ('isWrite', self.isWrite),%0A            ('file', self.targetFile),%0A            ('level', record.levelname),%0A            ('message', record.msg),%0A        %5D)%0A        if not self.plugin:%0A            del data%5B'plugin'%5D%0A        if not self.isWrite:%0A            del data%5B'isWrite'%5D%0A        return CustomEncoder().encode(data)%0A%0A    def formatException(self, exc_info):%0A        return sys.exec_info%5B2%5D.format_exc()%0A%0A%0Adef set_log_level(logger, args):%0A    level = logging.WARN%0A    if args.verbose:%0A        level = logging.DEBUG%0A    logger.setLevel(level)%0A%0A%0Adef setup_logging(args, version):%0A    logger = logging.getLogger('WakaTime')%0A    set_log_level(logger, args)%0A    if len(logger.handlers) %3E 0:%0A        formatter = JsonFormatter(datefmt='%25Y/%25m/%25d %25H:%25M:%25S %25z')%0A        formatter.setup(%0A            timestamp=args.timestamp,%0A            isWrite=args.isWrite,%0A            targetFile=args.targetFile,%0A            version=version,%0A            plugin=args.plugin,%0A        )%0A        logger.handlers%5B0%5D.setFormatter(formatter)%0A        return logger%0A    logfile = args.logfile%0A    if not logfile:%0A        logfile = '~/.wakatime.log'%0A    handler = logging.FileHandler(os.path.expanduser(logfile))%0A    formatter = JsonFormatter(datefmt='%25Y/%25m/%25d %25H:%25M:%25S %25z')%0A    formatter.setup(%0A        timestamp=args.timestamp,%0A        isWrite=args.isWrite,%0A        targetFile=args.targetFile,%0A        version=version,%0A        plugin=args.plugin,%0A    )%0A    handler.setFormatter(formatter)%0A    logger.addHandler(handler)%0A    return logger%0A

add missing logger.py file from wakatime component