forked from luna/vim-rana-local
upgrade wakatime-cli to v4.1.8
This commit is contained in:
parent
9fd813c489
commit
d6d31db5f0
6 changed files with 70 additions and 59 deletions
|
@ -11,9 +11,10 @@
|
|||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from .compat import u
|
||||
from .packages.requests.packages import urllib3
|
||||
try:
|
||||
from collections import OrderedDict # pragma: nocover
|
||||
except ImportError: # pragma: nocover
|
||||
|
@ -70,8 +71,9 @@ class JsonFormatter(logging.Formatter):
|
|||
del data['plugin']
|
||||
return CustomEncoder().encode(data)
|
||||
|
||||
def formatException(self, exc_info):
|
||||
return sys.exec_info[2].format_exc()
|
||||
|
||||
def traceback_formatter(*args, **kwargs):
|
||||
logging.getLogger('WakaTime').error(traceback.format_exc())
|
||||
|
||||
|
||||
def set_log_level(logger, args):
|
||||
|
@ -82,6 +84,7 @@ def set_log_level(logger, args):
|
|||
|
||||
|
||||
def setup_logging(args, version):
|
||||
urllib3.disable_warnings()
|
||||
logger = logging.getLogger('WakaTime')
|
||||
for handler in logger.handlers:
|
||||
logger.removeHandler(handler)
|
||||
|
@ -102,6 +105,9 @@ def setup_logging(args, version):
|
|||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
|
||||
# add custom traceback logging method
|
||||
logger.traceback = traceback_formatter
|
||||
|
||||
warnings_formatter = JsonFormatter(datefmt='%Y/%m/%d %H:%M:%S %z')
|
||||
warnings_formatter.setup(
|
||||
timestamp=args.timestamp,
|
||||
|
|
|
@ -412,6 +412,7 @@ def execute(argv=None):
|
|||
|
||||
setup_logging(args, __version__)
|
||||
|
||||
try:
|
||||
exclude = should_exclude(args.entity, args.include, args.exclude)
|
||||
if exclude is not False:
|
||||
log.debug(u('Skipping because matches exclude pattern: {pattern}').format(
|
||||
|
@ -421,8 +422,10 @@ def execute(argv=None):
|
|||
|
||||
if args.entity_type != 'file' or os.path.isfile(args.entity):
|
||||
|
||||
stats = get_file_stats(args.entity, entity_type=args.entity_type,
|
||||
lineno=args.lineno, cursorpos=args.cursorpos)
|
||||
stats = get_file_stats(args.entity,
|
||||
entity_type=args.entity_type,
|
||||
lineno=args.lineno,
|
||||
cursorpos=args.cursorpos)
|
||||
|
||||
project = args.project or args.alternate_project
|
||||
branch = None
|
||||
|
@ -468,3 +471,5 @@ def execute(argv=None):
|
|||
else:
|
||||
log.debug('File does not exist; ignoring this heartbeat.')
|
||||
return 0
|
||||
except:
|
||||
log.traceback()
|
||||
|
|
|
@ -44,9 +44,9 @@ class Git(BaseProject):
|
|||
with open(head, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
except IOError: # pragma: nocover
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
return None
|
||||
|
||||
def _project_base(self):
|
||||
|
|
|
@ -42,9 +42,9 @@ class Mercurial(BaseProject):
|
|||
with open(branch_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
except IOError: # pragma: nocover
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
return u('default')
|
||||
|
||||
def _find_hg_config_dir(self, path):
|
||||
|
|
|
@ -41,9 +41,9 @@ class WakaTimeProjectFile(BaseProject):
|
|||
self._project_name = u(fh.readline().strip())
|
||||
self._project_branch = u(fh.readline().strip())
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
except IOError: # pragma: nocover
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -191,5 +191,5 @@ def get_file_contents(file_name):
|
|||
with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
text = fh.read(512000)
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
log.traceback()
|
||||
return text
|
||||
|
|
Loading…
Reference in a new issue